Fix slot prop diagnostics inside Svelte 5 snippets#3030
Conversation
🦋 Changeset detectedLatest commit: 855319b The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
dummdidumm
left a comment
There was a problem hiding this comment.
Thank you! This isn't quite right yet - if you have this inside a snippet
{#snippet asd()}
<X>
<Y slot="foo" />
</X>
{/snippet}then it also counts as a slot. So we gotta reset the depth in that case.
We don't need this to be an integer btw, I think it's enough to say "you are inside a snippet". I also do wonder if the better change is to break the parent chain for elements/components. That change would be in htmllxtojsx_v2
8bc1f75 to
d94770a
Compare
7ac5fc9 to
887e9e7
Compare
that makes sense. I updated to the pr accordingly so the direct child case from the issue stays a normal prop: <Button>
{#snippet badge()}
<ButtonBadge slot="badge" />
{/snippet}
</Button>but nested component slot placement inside the snippet still works: {#snippet asd()}
<X>
<Y slot="foo" />
</X>
{/snippet} |
Fixes #2992.
slot="..."on a component directly inside a Svelte 5 snippet was being treated as legacy Svelte slot placement. That made the generated code read$$slot_deffrom the child component, which breaks for Svelte 5 wrapper components whose generated props includeRecord<string, unknown>.In this case, the snippet itself is already the slot API:
Here
slot="badge"should remain a normal prop/attribute onButtonBadge, so wrappers can forward it to a web component.This breaks the virtual element/component parent chain at the snippet boundary. Nested components inside the snippet still keep their own parent chain, so this continues to work as a Svelte slot:
{#snippet badge()} <X> <Y slot="foo" /> </X> {/snippet}Tested with the repro from #2992:
Also ran:
I also temporarily ran
svelte2tsxtests withsvelte@5.54.0locally: