Skip to content

Slotted content for Web Component nested inside of a Svelte component is not applied to the Web Component #1689

Open
@nsaunders

Description

@nsaunders

Given a Web Component which expects slotted children, which itself is nested inside of a Svelte component, as in the following:

<SvelteComponent>
  <my-custom-element>
    <div slot="slot1">my-custom-element content</div>
    <div slot="slot2">more my-custom-element content</div>
  </my-custom-element>
</SvelteComponent>

...the slotted children are not applied to the Web Component.

I have reproduced the issue here (just run npm install and npm run build and then open dist/index.html in your browser):
https://github.com/therealnicksaunders/svelte/tree/issue/slotted-content

In a more complicated example, this actually produces an error which suggests that a slotted child is being applied to the Svelte component instead of the Web Component in which it is nested. We have this Svelte-generated code:

(0, _shared.append)(pagecontent._slotted.header, div);

The referenced div is nested inside of a Web Component; its "slot" attribute of "header" corresponds to a slot inside of that Web Component rather than the PageContent Svelte component (which has no named slots).

Hopefully I have provided enough info here... Please let me know if I can clarify anything.

Thanks in advance for your help looking into it!

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