svelte icon indicating copy to clipboard operation
svelte copied to clipboard

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

Open CLDXiang opened this issue 1 year ago • 0 comments

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: https://github.com/sveltejs/svelte/blob/f579a3ba7d8f088d1d4f8625758e5e5598c9ebfa/packages/svelte/src/internal/client/dom/elements/custom-element.js#L267

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

CLDXiang avatar Oct 17 '24 08:10 CLDXiang