Skip to content

Forwarding slots #1824

@Rich-Harris

Description

@Rich-Harris

Not sure what the best way to frame this problem is, but: there currently needs to be a one-to-one (or one-to-zero) correspondence between slots in a child component, and slotted elements in the parent component, otherwise content goes missing. In some situations, that's a problem: REPL

Say we had a <Modal> component with a <slot></slot> and a <slot name="header"></slot>. If we wanted to lazily load that with a <Lazy> component whose implementation looked like this...

{#await loader() then mod}
  <svelte:component this={mod.default} on:close {...props}>
    <slot></slot>
  </svelte:component>
{/await}

<script>
  export default {
    computed: {
      props: ({ loader, ...props }) => props
    }
  };
</script>

...there's no way to 'forward' that header content.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions