Last active
October 13, 2016 00:00
-
-
Save PatrickKing/36983f91937ead08dd19a2455a11458c to your computer and use it in GitHub Desktop.
Behaviour of setAttributeNS in jsdom
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var jsdom = require("jsdom"); | |
var html = '<html><svg "xmlns=http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="100" height="100"></svg></html>'; | |
jsdom.env({ | |
features: { | |
QuerySelector: true | |
}, | |
html: html, | |
done: function(errors, window) { | |
var image = window.document.createElement("IMAGE"); | |
window.document.querySelector('svg').appendChild(image); | |
// image.setAttributeNS('http://www.w3.org/1999/xlink', 'xlink:href', 'my_image.svg'); | |
// Produces: <image xlink:href="my_image.svg"></image> | |
image.setAttributeNS('http://www.w3.org/1999/xlink', 'href', 'my_image.svg'); | |
// Produces: <image href="my_image.svg"></image> | |
// D3 makes calls like this. | |
console.log(window.document.querySelector('image').outerHTML) | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment