diff --git a/src/parser.js b/src/parser.js index f52df2fe..6b42c063 100644 --- a/src/parser.js +++ b/src/parser.js @@ -382,10 +382,10 @@ if (el) { return el; } - var node, i, idAttr, nodelist = doc.getElementsByTagName('*'); + var node, i, nodelist = doc.getElementsByTagName('*'); for (i = 0; i < nodelist.length; i++) { node = nodelist[i]; - if (idAttr === node.getAttribute('id')) { + if (id === node.getAttribute('id')) { return node; } } diff --git a/test/unit/parser.js b/test/unit/parser.js index a92f9a76..48e0c946 100644 --- a/test/unit/parser.js +++ b/test/unit/parser.js @@ -332,6 +332,25 @@ deepEqual(parsedAttributes.transformMatrix, [1, 0, 0, 1, 60, 10]); }); + asyncTest('parseSVGFromString id polyfill', function() { + var string = '' + + '' + + '' + + '', + rect; + + ok(fabric.loadSVGFromString); + + fabric.loadSVGFromString(string, function(objects) { + rect = objects[0]; + }); + + setTimeout(function() { + ok(rect instanceof fabric.Rect); + start(); + }, 1000); + }); + // asyncTest('parseSVGDocument', function() { // ok(fabric.parseSVGDocument);