sveltejs / rfcs

RFCs for changes to Svelte
274 stars 81 forks source link

Better slots and component composition. #39

Closed TheComputerM closed 3 years ago

TheComputerM commented 4 years ago

Rendered

This is my first RFC so please comment any helpful suggestions.

TheComputerM commented 4 years ago

Somewhat like https://github.com/sveltejs/svelte/pull/4556

lukeed commented 4 years ago

I was just going to link that – what are the differences? It looks like this is implemented as described

TheComputerM commented 4 years ago

This is still incomplete and I am brain storming on better syntax. The goal of it is to provide a more svelte like syntax and some additional features also such as slot options:

<Component>
  <svelte:fragment dense={true}>
    This will do something in the component
  </svelte:fragment>
</Component>
lukeed commented 4 years ago

Wouldn't slots just be a portal for where to render? The contents of what is rendered is determined by the content itself.

As far as I understand it, this RFC seems to be mostly about using svelte:fragment to render text nodes (non-component and non-element) with siblings.

I have an RFC open about inheriting <slot/> attributes (#15) But (imo) if you're passing dense={true} so that the slot can react/alter its display, then I think that falls more into svelte:template territory (#34).

But, I might be misunderstanding you completely. I'm sorta guessing at the examples

TheComputerM commented 4 years ago

Yeah, sorry for the short explanation. Was thinking more on the lines of something like this: The syntax is just for better understanding.

<svelte:slot tag={ListItem} export:dense on:click={func}>
  Default
</svelte:slot>
<svelte:fragment dense={true}>
  Content
</svelte:fragment>
<ListItem dense={true} on:click={func}>
  Content
</ListItem>
TheComputerM commented 4 years ago

This was mainly intended to solve https://github.com/sveltejs/svelte/issues/2079 and add some new features.

lukeed commented 4 years ago

No problem

Yeah, to me that's 100% an inline component, if not an external component. Either of which only get placed by a <slot>