diff --git a/.changeset/eight-waves-mate.md b/.changeset/eight-waves-mate.md new file mode 100644 index 0000000000..3c6dd1b776 --- /dev/null +++ b/.changeset/eight-waves-mate.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +fix: avoid migrating slots in custom elements diff --git a/packages/svelte/src/compiler/migrate/index.js b/packages/svelte/src/compiler/migrate/index.js index d3b386aed2..9b1dc00e57 100644 --- a/packages/svelte/src/compiler/migrate/index.js +++ b/packages/svelte/src/compiler/migrate/index.js @@ -599,6 +599,7 @@ const template = { next(); }, SlotElement(node, { state, next }) { + if (state.analysis.custom_element) return; let name = 'children'; let slot_name = 'default'; let slot_props = '{ '; diff --git a/packages/svelte/tests/migrate/samples/slots-custom-element/input.svelte b/packages/svelte/tests/migrate/samples/slots-custom-element/input.svelte new file mode 100644 index 0000000000..3063b32517 --- /dev/null +++ b/packages/svelte/tests/migrate/samples/slots-custom-element/input.svelte @@ -0,0 +1,23 @@ + + + + + + +{count} + +{#if foo} + +{/if} + +{#if $$slots.bar} + {$$slots} + +{/if} + +{#if $$slots.default}foo{/if} + + diff --git a/packages/svelte/tests/migrate/samples/slots-custom-element/output.svelte b/packages/svelte/tests/migrate/samples/slots-custom-element/output.svelte new file mode 100644 index 0000000000..8f530891a2 --- /dev/null +++ b/packages/svelte/tests/migrate/samples/slots-custom-element/output.svelte @@ -0,0 +1,23 @@ + + + + + + +{count} + +{#if foo} + +{/if} + +{#if bar} + {$$slots} + +{/if} + +{#if children}foo{/if} + + \ No newline at end of file