-
Notifications
You must be signed in to change notification settings - Fork 69
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
.svgString() automatically lowercases tags? #13
Comments
The reason for this seems to go way beyond d3-node and d3 itself... |
@KingZee great find. Thx. |
@KingZee if you could share the d3 script you were using to produce this issue, it was be appreciated. |
Here's my code. So since svgString() is equivalent of getting the svg.node().outerHTML, and HTML isn't case sensitive, the output tags are all lowercased, I have managed to tweak this by instead getting the XML using xmlserializer, I parse the node directly, so something like :
The output will take into account case sensitivity. Since this adds dependency to xmlserializer it's up to you if you want to add this fix, I couldn't find another way to work around this. Cheers. |
Ok, I'm going to attempt a fix and a test for this. |
This may also be resolved (at some point) via jsdom with jsdom/jsdom#1368 |
@KingZee |
To reproduce, insert any element with a tag containing uppercase using selection.html(), and print it with the svg.svgString() function.
This is a sample output I'm getting :
<svg xmlns="http://www.w3.org/2000/svg" width="500" height="50"><radialgradient id="grad1" x1="10%" y1="10%" x2="80%" y2="90%"> <stop offset="0%" style="stop-color:#627AAD;stop-opacity:0.9"></stop> <stop offset="100%" style="stop-color:#3B5998;stop-opacity:0.9"></stop> </radialgradient><circle cx="25" cy="25" r="5" fill="url(#grad1)"></circle><circle cx="75" cy="25" r="10" fill="url(#grad1)"></circle><circle cx="125" cy="25" r="15" fill="url(#grad1)"></circle><circle cx="175" cy="25" r="20" fill="url(#grad1)"></circle><circle cx="225" cy="25" r="25" fill="url(#grad1)"></circle></svg>
Because svgString() lowercases the g in
radialGradient
, it will break the file, and the above svg does not get rendered.You can take the above svg and change the
radialgradient
toradialGradient
, it renders correctly.The text was updated successfully, but these errors were encountered: