-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Not rendering multiple SVG elements #130
Comments
Ok... found the problem! It's in https://github.com/sveltejs/svelte/blob/master/compiler/generate/visitors/Element.js The piece of code that evaluates whether the element is an svg evaluates on the exact match on the string 'svg'. The first svg element passed to this function will have the name 'svg', but subsequent svg elements will be numbered. ie 'svg2', 'svg3'. So the subsequent elements fail the test as they do not match 'svg' exactly. The following change is needed to fix it. Original
new code
Essentially changing the evaluation to the first three letters of the element name, and not the whole name. |
Thanks! Fixed in 1.1.1 |
Ha! Just submitted a pull request to fix this.. will cancel it! You're too quick! Thank you! |
Bear in mind, that this should affect other SVG elements like |
When I have multiple svg elements in a component it is only rendering the first element correctly, but subsequent elements are not rendered. Looked into the compiled code, and it uses createElementNS as shown below to create the first svg element
var svg = document.createElementNS( 'http://www.w3.org/2000/svg', 'svg' );
but subsequent svg's don't use the createElementNS and just use createElement without specifying the svg schema like below.
var svg2 = document.createElement( 'svg' );
All nested elements below the svg elements will follow the convention of the parent element.
The text was updated successfully, but these errors were encountered: