Skip to content

slot/snippet and custom elements broken/usage unclear #15882

Open
@mspae

Description

@mspae

Describe the bug

The usage of snippets (and slots) within custom elements is not clear from the documentation. The resulting order of DOM nodes is different between using a svelte component "normally" and as a custom element. I'm assuming this is unavoidable and due to the special nature of custom elements. However, the corresponding caveats for using slots/snippets within custom elements (assuming there some footguns lying around) are not documented on this page so I'm at a loss how to mitigate this issue.

I think this is probably the same issue as #12892 - the resolution of that issue ("use slots") is not clear to me. I'm probably missing something.

Reproduction

https://svelte.dev/playground/87c914a892664f7990bae0fa38290278?version=5.28.2

(Same thing using the @render syntax https://svelte.dev/playground/d9ae949baaea4276a6bd6edcdb03a451?version=5.28.2)

Logs

System Info

System:
    OS: Linux 6.1 Debian GNU/Linux 12 (bookworm) 12 (bookworm)
    CPU: (4) x64 Intel Core Processor (Skylake, IBRS)
    Memory: 7.04 GB / 7.75 GB
    Container: Yes
    Shell: 5.2.15 - /bin/bash
  Binaries:
    Node: 20.19.1 - /usr/bin/node
    npm: 10.8.2 - /usr/bin/npm

Severity

blocking all usage of svelte

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