Skip to content

div within svg is not treated equally by the compiler if the div is in a component #6385

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

Closed
firewave-remo opened this issue Jun 5, 2021 · 5 comments

Comments

@firewave-remo
Copy link

Describe the bug
Sorry for the confusing title, but i had no better idea. And it's much easier to see it in the REPL than describing it.

I have an svg element and try to add a Component with a foreignObject in it and a default slot. In the first case the div element is part of the slot and in the second case the div is part of the component.

In the first case the compiler creates an svg_element and in the second the compiler creates a normal element. (As seen in the JS Output Tab) I think the first case is the correct case, because there is no xmlns attribute on the div. I have tried to show that in the more fleshed out REPL. I don't know if this is worth to be fixed, but i stumbled over this bug and i wanted to show this.

To Reproduce
Minimal REPL
https://svelte.dev/repl/52d3b5cdb017498e82eb2d958fdc2782?version=3.38.2

More fleshed out REPL
https://svelte.dev/repl/0564bbb5485840d0909593059b77185f?version=3.38.2

Expected behavior
Same Output at least. In the minimal REPL the first part where nothing is shown is the correct part i think, because it has no xmlns attribute. But otherwise there is no div-svg element at all https://developer.mozilla.org/en-US/docs/Web/SVG/Element so maybe a compiler warning would be nice?

Severity
Just confusing behavior.

@firewave-remo firewave-remo changed the title div withing svg are not treated equally by the compiler if the div is in a component div within svg are not treated equally by the compiler if the div is in a component Jun 5, 2021
@firewave-remo firewave-remo changed the title div within svg are not treated equally by the compiler if the div is in a component div within svg is not treated equally by the compiler if the div is in a component Jun 5, 2021
@karolwydmuch
Copy link

It's really weird but when you add this attr to your div

xmlns="http://www.w3.org/1999/xhtml"

It works: https://developer.mozilla.org/en-US/docs/Web/SVG/Element/foreignObject

@firewave-remo
Copy link
Author

Yes i know that and i have already written that in the issue and it's already part of the fleshed out example.

The Point is, that the svelte compiler does different things even tough the compiler should do the same thing.

@stale
Copy link

stale bot commented Dec 5, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale-bot label Dec 5, 2021
@stale
Copy link

stale bot commented Dec 19, 2021

This issue has been closed as it was previously marked as stale and saw no subsequent activity.

@stale stale bot closed this as completed Dec 19, 2021
@SystemParadox
Copy link

@Rich-Harris this is still an issue, please can we reopen? The above REPL clearly shows the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants