fix: migrate default slots to children snippet (#13760)

Closes #13758
pull/13761/head
Paolo Ricciuti 11 months ago committed by GitHub
parent ef205d960e
commit 9832c639e5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -0,0 +1,5 @@
---
'svelte': patch
---
fix: migrate default slots to children snippet

@ -1152,6 +1152,10 @@ function migrate_slot_usage(node, path, state) {
is_text_attribute(attribute)
) {
snippet_name = attribute.value[0].data;
// the default slot in svelte 4 if what the children slot is for svelte 5
if (snippet_name === 'default') {
snippet_name = 'children';
}
if (!regex_is_valid_identifier.test(snippet_name)) {
has_migration_task = true;
state.str.appendLeft(

@ -77,6 +77,14 @@
<div slot="bar">bar</div>
</Component>
<Component>
<span slot="default">should be children</span>
</Component>
<Component>
<span slot="default" let:with_prop>should be children {with_prop} too</span>
</Component>
<c-e>
<div slot="named">unchanged</div>
</c-e>

@ -121,6 +121,16 @@
{/snippet}
</Component>
<Component>
<span >should be children</span>
</Component>
<Component>
<span >{#snippet children({ with_prop })}
should be children {with_prop} too {/snippet}
</span>
</Component>
<c-e>
<div slot="named">unchanged</div>
</c-e>
Loading…
Cancel
Save