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

Svelte 5: Invalid namespace of elements within SVG #11993

Closed
mspae opened this issue Jun 11, 2024 · 5 comments · Fixed by #12598
Closed

Svelte 5: Invalid namespace of elements within SVG #11993

mspae opened this issue Jun 11, 2024 · 5 comments · Fixed by #12598
Milestone

Comments

@mspae
Copy link

mspae commented Jun 11, 2024

Describe the bug

In certain situations* the elements inside SVG elements appear to have an invalid namespace which means they are shown in the inspector (DOM tree) but are not actually visible.

*] Such as using conditions and snippets in an svg element. Correction: When using a <svelte:element> whose this property expression is defined inside a closure (f.x. inside a snippet as a @const)

A similiar issue seems to have popped up several times through the years: https://github.com/sveltejs/svelte/issues?q=is%3Aissue+is%3Aopen+namespace+svg

Reproduction

https://svelte-5-preview.vercel.app/#H4sIAAAAAAAAA-1XXW_bNhT9K4S6hwQQaZGiJVt1sm5ZMwzIiqHF9jINgyMrtgBZEiQmTmD4v-9cUlaaeOm6D9Qvg2Fbury8H-dc8UBb76Yo885Lft161Xyde4n3TdN4vmceGrrp7vLS5Ljv6ts2I8usy9qiMedpxVixburWsHd1u56XH-6W7Kat1yz1xGgwCRch9V6nVWr6Dd89IFeRvS3zdV6ZJxsPlj4OMBsNyXGzCs9dGvbhl-99VtWsaetrbExmI6zB47Gw0bAFvmxTmBVbuEwsd6mGTYfF7Xd35qHM6dIky7K-npcn3d3ylG3Jkpr61pRFlSdMNvesq8tiwdrl9fwk8O1HjE9fO8f1_J5vioVZwTXI19a6s8318QH3ul4UN0W-8BLT3uY7f2BnaOnTHKHq-3VZdWeptzKmSUajzWYjNqGo2-VIBUEwgkvqsbsi33xb38MtYAGbToRkUk5Sz9I7a-ZmRReMYUpKOL26vAzfBkHqOesCph-nUkx8ORbRxSQQUx4I6Y-nQnEtYl-HIvLHQl3JCGalxORiAouKxdg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

System Info

System:
    OS: Linux 5.10 Debian GNU/Linux 11 (bullseye) 11 (bullseye)
    CPU: (4) x64 Intel Core Processor (Skylake, IBRS)
    Memory: 6.80 GB / 7.76 GB
    Container: Yes
    Shell: 5.1.4 - /bin/bash
  Binaries:
    Node: 20.13.1 - /usr/bin/node
    npm: 10.5.2 - /usr/bin/npm
  Browsers:
    Chrome: 125.0.6422.112
  npmPackages:
    @astrojs/svelte: ^5.5.0 => 5.5.0 
    astro: ^4.9.2 => 4.9.2 
    svelte: ^5.0.0-next.151 => 5.0.0-next.151

Severity

blocking an upgrade

Update

Fixed wrong error description and update reproduction REPL link

@mspae
Copy link
Author

mspae commented Jun 11, 2024

I forgot to mention: Using <svelte:options namespace="svg" /> does not have any effect.

I was able to get the element to show using a use: directive like this to dynamically change the elements namespace: #7807 (comment)

@dummdidumm
Copy link
Member

I can't reproduce this. The REPL works as expected: If I add shouldRender to the <SvgWithCondition /> component it shows the path (it's invisible because it has white fill, changing the color reveals it).

Please state the steps to reproduce this.

@dummdidumm dummdidumm added the awaiting submitter needs a reproduction, or clarification label Jun 11, 2024
@mspae
Copy link
Author

mspae commented Jun 11, 2024

Oops. Sorry, you're totally right. I seem to have been confused 🙈

The issue happens when using a dynamic element (<svelte:element>) within an svg but only when defining the tag expression inside the close (f.x. the snippet)

Here is an updared reproduction:

https://svelte-5-preview.vercel.app/#H4sIAAAAAAAAA-1XXW_bNhT9K4S6hwQQaZGiJVt1sm5ZMwzIiqHF9jINgyMrtgBZEiQmTmD4v-9cUlaaeOm6D9Qvg2Fbury8H-dc8UBb76Yo885Lft161Xyde4n3TdN4vmceGrrp7vLS5Ljv6ts2I8usy9qiMedpxVixburWsHd1u56XH-6W7Kat1yz1xGgwCRch9V6nVWr6Dd89IFeRvS3zdV6ZJxsPlj4OMBsNyXGzCs9dGvbhl-99VtWsaetrbExmI6zB47Gw0bAFvmxTmBVbuEwsd6mGTYfF7Xd35qHM6dIky7K-npcn3d3ylG3Jkpr61pRFlSdMNves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vTk53rqDtm2GKzvYjxPq1Z3yzgeqeacaeMa3-hOnLZzR_MdU8omZ-WcU8il4eSy2PrJXHVMoj62T_wmW2o_4M2fUnzJvWidrhAeNk1b3jtU5oV_r8HRS1a-ZZ3tHbnYb1J1KJhDm1YF87JRTV3u_n9z-wBALHObtFphu8zy0Y56m3m127sBRA9QFUH0B9ToBDyf9t9weK7zAyfg8AAA==

@dummdidumm
Copy link
Member

It's not possible for Svelte to know what namespace to assign to the dynamic element because it's inside a snippet and therefore could be rendered from anywhere. What you can do in these situations is add xmlns="http://www.w3.org/2000/svg" to the <svelte:element> tag.
Giving this the documentation label, we should add this info to the docs.

@dummdidumm dummdidumm added documentation and removed awaiting submitter needs a reproduction, or clarification labels Jun 11, 2024
@dummdidumm dummdidumm added this to the 5.0 milestone Jun 11, 2024
@mspae
Copy link
Author

mspae commented Jun 11, 2024

Great, thanks for the info!

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

Successfully merging a pull request may close this issue.

2 participants