Skip to content
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

SVG @html element not rentering from string #7450

Closed
sbstnzmr opened this issue Apr 13, 2022 · 8 comments · Fixed by #7464
Closed

SVG @html element not rentering from string #7450

sbstnzmr opened this issue Apr 13, 2022 · 8 comments · Fixed by #7464
Labels
bug runtime Changes relating to runtime APIs

Comments

@sbstnzmr
Copy link

Describe the bug

When composing a svg from a string, elements are not rendered.

In the example both circles look the same in the DOM (with a different position and color). The element from the string only renders if no other element is in the svg. If it is alone, it works.

Reproduction

https://svelte.dev/repl/39625f96ce6941f8b7ca41f7e43738a7?version=3.47.0

Logs

No response

System Info

see REPL

Severity

annoyance

@dummdidumm
Copy link
Member

When I open dev tools I see the element appearing in the Elements view, not sure what this hints at.

@sbstnzmr
Copy link
Author

Bildschirmfoto 2022-04-13 um 15 53 50

The second svg should have two circles. The one from the left from a string and the one from the right as a direct element.

@baseballyama
Copy link
Member

I think the reason is that the namespace is not svg.
This is bug.

@sbstnzmr
Copy link
Author

It works if it's the only thing in the svg tag

<svg width="{width}" height="{height}">
	{@html circle}
</svg>

It does not if there is another element

<svg width="{width}" height="{height}">
	{@html circle}
	<circle cx="{width/4*3}" cy="{height/2}" r="24" fill="#118AB2"/>
</svg>

That one looks like

<svg width="{width}" height="{height}">
	<circle cx="{width/4*3}" cy="{height/2}" r="24" fill="#118AB2"/>
</svg>

but in the inspector I can see 2 elements for the example with 2 circles.

@Prinzhorn
Copy link
Contributor

I think the reason is that the namespace is not svg.
This is bug.

Yep

Array.from(document.querySelectorAll('circle')).map(e => e.namespaceURI)

0: "http://www.w3.org/2000/svg"
1: "http://www.w3.org/1999/xhtml" <================
2: "http://www.w3.org/2000/svg"
3: "http://www.w3.org/2000/svg"

@dummdidumm dummdidumm added bug runtime Changes relating to runtime APIs labels Apr 13, 2022
@baseballyama
Copy link
Member

related issue: #7002

@dimfeld
Copy link
Contributor

dimfeld commented Apr 15, 2022

I documented a workaround at #5764 (comment)

@Conduitry
Copy link
Member

This should be fixed now in 3.48.0 - https://svelte.dev/repl/39625f96ce6941f8b7ca41f7e43738a7?version=3.48.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug runtime Changes relating to runtime APIs
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants