Fix getElementByID polyfill and added failing test for it

This commit is contained in:
Andrea Bogazzi 2015-08-11 00:39:50 +02:00
parent b24f211dfa
commit 3520a51d21
2 changed files with 21 additions and 2 deletions

View file

@ -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;
}
}

View file

@ -332,6 +332,25 @@
deepEqual(parsedAttributes.transformMatrix, [1, 0, 0, 1, 60, 10]);
});
asyncTest('parseSVGFromString id polyfill', function() {
var string = '<?xml version="1.0" standalone="no"?><svg width="100%" height="100%" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">' +
'<defs><rect id="myrect" width="300" height="100" style="fill:rgb(0,0,255);stroke-width:1;stroke:rgb(0,0,0)"/></defs>' +
'<use xlink:href="#myrect" x="50" y="50" ></use>' +
'</svg>',
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);