Skip to content

Snippets and slots interop #13067

@rChaoz

Description

@rChaoz

Describe the bug

After seeing #13063, playing around a bit and opening #13066, I've realised that interop between snippets and slots seems to be inexistent except for the default slot, which only works sometimes (see mentioned issues for details). But the docs mention about slots that:

They continue to work, however, and you can mix and match snippets and slots in your components.

The previous issue opened was a documentation issue, however I say this is a bug - it is impossible to use Svelte 4 components with slots from Svelte 5 code with snippets. It is possible to mostly workaround this, since you can use <something slot="x"> and snippets/renders in the same file, but you cannot use <slot> and snippets in the same file.

Additionally, I have a question: could there be interop between snippet arguments and slot props?

<!-- Child -->
<slot name="named" prop1={item1} prop2={item2} />

<!-- Parent -->
<Child>
  {#snippet named({ prop1, prop2 })}
    ...
  {/snippet}
</Child>

or

<!-- Child -->
<script>
  let { named } = $props()
</script>
{@render named({ prop1: "abc", prop2: 123 })}

<!-- Parent -->
<Child let:prop1 let:prop2>
  ...
</Child>

Severity

blocking an upgrade

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions