Skip to content

Svelte 5: Custom element's default <slot> not created when no initial children are passed #13638

Open
@CLDXiang

Description

@CLDXiang

Describe the bug

When Svelte creates a custom element, if no child elements are initially passed in, the default <slot> tag will not be created, causing subsequently added child elements to not be rendered in the slot.

It seems that this part might be responsible:

result[/** @type {Element} node */ (node).slot || 'default'] = true;

Hope this helps with troubleshooting the issue.

Reproduction

https://github.com/CLDXiang/svelte-custom-element-no-default-slot-bug

Initial state:
image

Append some children:
image

Logs

No response

System Info

System:
    OS: macOS 15.0.1
    CPU: (20) x64 Intel(R) Core(TM) i9-10910 CPU @ 3.60GHz
    Memory: 158.62 MB / 32.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 18.20.4 - ~/.nvm/versions/node/v18.20.4/bin/node
    npm: 10.7.0 - ~/.nvm/versions/node/v18.20.4/bin/npm
    pnpm: 9.12.1 - ~/.nvm/versions/node/v18.20.4/bin/pnpm
    bun: 1.0.11 - ~/.bun/bin/bun
  Browsers:
    Chrome: 129.0.6668.101
    Safari: 18.0.1

Severity

annoyance

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions