Skip to content

Forwarding slots #1824

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Rich-Harris opened this issue Oct 30, 2018 · 6 comments
Closed

Forwarding slots #1824

Rich-Harris opened this issue Oct 30, 2018 · 6 comments

Comments

@Rich-Harris
Copy link
Member

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.

@Conduitry
Copy link
Member

I think this idea got absorbed into the other composition improvements.

@dxlbnl
Copy link
Contributor

dxlbnl commented Oct 23, 2019

This issue can be closed

@j3rem1e
Copy link

j3rem1e commented Jun 24, 2020

Is there today a workaround/hack to implement this kind of forwarding ?

I am trying to implements this usecase (a generic lazy loader component which forwards slots/events to the "real" component).

@swyxio
Copy link
Contributor

swyxio commented Jun 13, 2021

i think this is still not precisely working as of svelte 3 https://svelte.dev/repl/d329e911978c4d7f89fc991b66fe9a91?version=3.38.2

@stale
Copy link

stale bot commented Dec 24, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale-bot label Dec 24, 2021
@Rich-Harris
Copy link
Member Author

I think we can close this now that Svelte 5 has snippets

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants