From ad21b2b07a2dbff7b78b79a3b6d616de7d1a0aa4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=BCrg=20Lehni?= <juerg@scratchdisk.com>
Date: Mon, 1 Feb 2016 20:09:43 +0100
Subject: [PATCH] SVG: Pass the imported SVG date as the 2nd parameter to
 onLoad()

---
 src/item/Item.js     | 11 +++++++----
 src/item/Project.js  | 25 ++++++++++++++-----------
 src/svg/SvgImport.js |  2 +-
 3 files changed, 22 insertions(+), 16 deletions(-)

diff --git a/src/item/Item.js b/src/item/Item.js
index b7376cd3..dabf279d 100644
--- a/src/item/Item.js
+++ b/src/item/Item.js
@@ -2121,9 +2121,10 @@ new function() { // // Scope to inject various item event handlers
      *
      * @option [options.expandShapes=false] {Boolean} whether imported shape
      *     items should be expanded to path items
-     * @option [options.onLoad] {Function} the callback function to call once
-     *     the SVG content is loaded from the given URL. Only required when
-     *     loading from external files.
+     * @option options.onLoad {Function} the callback function to call once the
+     *     SVG content is loaded from the given URL receiving two arguments: the
+     *     converted `item` and the original `svg` data as a string. Only
+     *     required when loading from external files.
      * @option [options.applyMatrix={@link PaperScope#settings}.applyMatrix]
      *     {Boolean} whether imported items should have their transformation
      *     matrices applied to their contents or not
@@ -2145,7 +2146,9 @@ new function() { // // Scope to inject various item event handlers
      *
      * @param {SVGElement|String} svg the URL of the SVG file to fetch.
      * @param {Function} onLoad the callback function to call once the SVG
-     *     content is loaded from the given URL.
+     *     content is loaded from the given URL receiving two arguments: the
+     *     converted `item` and the original `svg` data as a string. Only
+     *     required when loading from external files.
      * @return {Item} the newly created Paper.js item containing the converted
      *     SVG content
      */
diff --git a/src/item/Project.js b/src/item/Project.js
index 2893b144..cfd0b75a 100644
--- a/src/item/Project.js
+++ b/src/item/Project.js
@@ -757,20 +757,21 @@ var Project = PaperScopeItem.extend(/** @lends Project# */{
      * @function
      *
      * @option [options.expandShapes=false] {Boolean} whether imported shape
-     * items should be expanded to path items
-     * @option [options.onLoad] {Function} the callback function to call once
-     * the SVG content is loaded from the given URL. Only required when loading
-     * from external files.
+     *     items should be expanded to path items
+     * @option options.onLoad(item, svg) {Function} the callback function to
+     *     call once the SVG content is loaded from the given URL receiving two
+     *     arguments: the converted `item` and the original `svg` data as a
+     *     string. Only required when loading from external files.
      * @option [options.applyMatrix={@link PaperScope#settings}.applyMatrix]
-     * {Boolean} whether imported items should have their transformation
-     * matrices applied to their contents or not
+     *     {Boolean} whether imported items should have their transformation
+     *     matrices applied to their contents or not
      *
      * @param {SVGElement|String} svg the SVG content to import, either as a SVG
-     * DOM node, a string containing SVG content, or a string describing the URL
-     * of the SVG file to fetch.
+     *     DOM node, a string containing SVG content, or a string describing the
+     *     URL of the SVG file to fetch.
      * @param {Object} [options] the import options
      * @return {Item} the newly created Paper.js item containing the converted
-     * SVG content
+     *     SVG content
      */
     /**
      * Imports the provided external SVG file, converts it into Paper.js items
@@ -783,9 +784,11 @@ var Project = PaperScopeItem.extend(/** @lends Project# */{
      *
      * @param {SVGElement|String} svg the URL of the SVG file to fetch.
      * @param {Function} onLoad the callback function to call once the SVG
-     * content is loaded from the given URL.
+     *     content is loaded from the given URL receiving two arguments: the
+     *     converted `item` and the original `svg` data as a string. Only
+     *     required when loading from external files.
      * @return {Item} the newly created Paper.js item containing the converted
-     * SVG content
+     *     SVG content
      */
 
     removeOn: function(type) {
diff --git a/src/svg/SvgImport.js b/src/svg/SvgImport.js
index 9a500d20..bd584f1d 100644
--- a/src/svg/SvgImport.js
+++ b/src/svg/SvgImport.js
@@ -563,7 +563,7 @@ new function() {
                 onLoad = options.onLoad,
                 view = scope.project && scope.getView();
             if (onLoad)
-                onLoad.call(this, item);
+                onLoad.call(this, item, svg);
         }
 
         if (isRoot) {