Skip to content

Commit

Permalink
Merge pull request #69 from canjs/fix-svgs
Browse files Browse the repository at this point in the history
handling attributes namespace URI
  • Loading branch information
cherifGsoul committed Nov 9, 2018
2 parents 19dfe70 + 52bd548 commit be196f1
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
4 changes: 3 additions & 1 deletion can-view-target.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,9 @@ function processNode(node, paths, location, document){
getCallback().callbacks.push({
callback: value
});
} else {
} else if (value !== null && typeof value === "object" && value.namespaceURI) {
el.setAttributeNS(value.namespaceURI,attrName,value.value);
} else {
domMutate.setAttribute.call(el, attrName, value);
}
}
Expand Down
14 changes: 14 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,3 +185,17 @@ test('cloneNode keeps non-default element namespace', function() {

equal(clone.firstChild.namespaceURI, 'http://www.w3.org/2000/svg', 'cloneNode should keep non-default element namespace');
});

QUnit.test("SVG namespaceURI", function() {
var data = target([{
tag: "svg",
attrs: {
"xmlns" : {
value: "http://www.w3.org/2000/svg",
namespaceURI: "http://www.w3.org/2000/xmlns/"
}
}
}]);
var frag = data.hydrate();
QUnit.equal(frag.firstChild.getAttributeNode("xmlns").namespaceURI, 'http://www.w3.org/2000/xmlns/');
})

0 comments on commit be196f1

Please sign in to comment.