diff --git a/dist/all.js b/dist/all.js index f9afe19f..6d97196f 100644 --- a/dist/all.js +++ b/dist/all.js @@ -2788,7 +2788,8 @@ fabric.util.animate = animate; } } - elements.map(function(el, index) { + for (var index = 0, el, len = elements.length; index < len; index++) { + el = elements[index]; var klass = fabric[capitalize(el.tagName)]; if (klass && klass.fromElement) { try { @@ -2812,7 +2813,7 @@ fabric.util.animate = animate; else { checkIfDone(); } - }); + } }; /** @@ -2892,18 +2893,19 @@ fabric.util.animate = animate; */ fabric.parseSVGDocument = (function() { - var reAllowedSVGTagNames = /^(path|circle|polygon|polyline|ellipse|rect|line|image)$/, - - reNum = '(?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?)', - - reViewBoxAttrValue = new RegExp( - '^' + - '\\s*(' + reNum + '+)\\s*,?' + - '\\s*(' + reNum + '+)\\s*,?' + - '\\s*(' + reNum + '+)\\s*,?' + - '\\s*(' + reNum + '+)\\s*' + - '$' - ); + var reAllowedSVGTagNames = /^(path|circle|polygon|polyline|ellipse|rect|line|image)$/; + + + var reNum = '(?:[-+]?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?)'; + + var reViewBoxAttrValue = new RegExp( + '^' + + '\\s*(' + reNum + '+)\\s*,?' + + '\\s*(' + reNum + '+)\\s*,?' + + '\\s*(' + reNum + '+)\\s*,?' + + '\\s*(' + reNum + '+)\\s*' + + '$' + ); function hasAncestorWithNodeName(element, nodeName) { while (element && (element = element.parentNode)) { @@ -8737,10 +8739,8 @@ fabric.util.animate = animate; * @return {fabric.Path} Instance of fabric.Path */ fabric.Path.fromElement = function(element, options) { - var parsedAttributes = fabric.parseAttributes(element, fabric.Path.ATTRIBUTE_NAMES), - path = parsedAttributes.d; - delete parsedAttributes.d; - return new fabric.Path(path, extend(parsedAttributes, options)); + var parsedAttributes = fabric.parseAttributes(element, fabric.Path.ATTRIBUTE_NAMES); + return new fabric.Path(parsedAttributes.d, parsedAttributes ? extend(parsedAttributes, options) : undefined); }; })(this); diff --git a/src/parser.js b/src/parser.js index e649b4d3..46927e90 100644 --- a/src/parser.js +++ b/src/parser.js @@ -331,8 +331,9 @@ callback(instances); } } - - elements.map(function(el, index) { + + for (var index = 0, el, len = elements.length; index < len; index++) { + el = elements[index]; var klass = fabric[capitalize(el.tagName)]; if (klass && klass.fromElement) { try { @@ -356,7 +357,7 @@ else { checkIfDone(); } - }); + } }; /** diff --git a/src/path.class.js b/src/path.class.js index 7ea3bf27..9c51e2df 100644 --- a/src/path.class.js +++ b/src/path.class.js @@ -511,9 +511,7 @@ * @return {fabric.Path} Instance of fabric.Path */ fabric.Path.fromElement = function(element, options) { - var parsedAttributes = fabric.parseAttributes(element, fabric.Path.ATTRIBUTE_NAMES), - path = parsedAttributes.d; - delete parsedAttributes.d; - return new fabric.Path(path, extend(parsedAttributes, options)); + var parsedAttributes = fabric.parseAttributes(element, fabric.Path.ATTRIBUTE_NAMES); + return new fabric.Path(parsedAttributes.d, extend(parsedAttributes, options)); }; })(this); \ No newline at end of file diff --git a/src/util/lang_object.js b/src/util/lang_object.js index 45b85f3c..a1964f44 100644 --- a/src/util/lang_object.js +++ b/src/util/lang_object.js @@ -5,7 +5,7 @@ * @param {Object} destination Where to copy to * @param {Object} source Where to copy from */ -function extend(destination, source) { +function extend(destination, source) { // JScript DontEnum bug is not taken care of for (var property in source) { destination[property] = source[property]; diff --git a/test/raphael_vs_fabric/complex_shape_2.html b/test/raphael_vs_fabric/complex_shape_2.html index d5a3eb3a..41b787e0 100644 --- a/test/raphael_vs_fabric/complex_shape_2.html +++ b/test/raphael_vs_fabric/complex_shape_2.html @@ -29,7 +29,7 @@ var logEl = document.getElementById('log'); - (function testRaphael() { + /*(function testRaphael() { var start = function () { // storing original coordinates @@ -56,6 +56,7 @@ logEl.innerHTML = 'Raphael: ' + (new Date() - startTime) + 'ms
'; })(); + */ (function testFabric() {