Skip to content

Svelte 5: SVG elements within <slot> fallback not displayed #11847

@techniq

Description

@techniq

Describe the bug

If an SVG element (ex. <circle>) is placed within a <slot> as the fallback, the element is not visible, even though the markup is correct.

<slot>
  <circle cx={10} cy={10} r={5} />
  <circle cx={20} cy={20} r={5} />
  <circle cx={30} cy={30} r={5} />
  <circle cx={40} cy={40} r={5} />
  <circle cx={50} cy={50} r={5} />
</slot>

Removing the <slot> wrapper or adding <svelte:options namespace="svg" /> at the top of the component works around the issue.

This is likely due to the element being created with document.createElement("circle") instead of
document.createElementNS("http://www.w3.org/2000/svg", "circle");.

Related issue: #11219

Reproduction

Logs

No response

System Info

Svelte 5 REPL

Severity

blocking an upgrade

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions