From 3520a51d21038ebe9fc4347385e93cc1581e5154 Mon Sep 17 00:00:00 2001 From: Andrea Bogazzi Date: Tue, 11 Aug 2015 00:39:50 +0200 Subject: [PATCH] Fix getElementByID polyfill and added failing test for it --- src/parser.js | 4 ++-- test/unit/parser.js | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) 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);