Skip to content

Commit ffa1527

Browse files
committed
fix: avoid migrating slots in custom elements
1 parent 9627426 commit ffa1527

File tree

4 files changed

+38
-0
lines changed

4 files changed

+38
-0
lines changed

.changeset/eight-waves-mate.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'svelte': patch
3+
---
4+
5+
fix: avoid migrating slots in custom elements

packages/svelte/src/compiler/migrate/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -583,6 +583,7 @@ const template = {
583583
next();
584584
},
585585
SlotElement(node, { state, next }) {
586+
if (state.analysis.custom_element) return;
586587
let name = 'children';
587588
let slot_name = 'default';
588589
let slot_props = '{ ';
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<svelte:options customElement="my-element" />
2+
3+
<button><slot /></button>
4+
5+
{#if foo}
6+
<slot name="foo" {foo} />
7+
{/if}
8+
9+
{#if $$slots.bar}
10+
{$$slots}
11+
<slot name="bar" />
12+
{/if}
13+
14+
{#if $$slots.default}foo{/if}
15+
16+
<slot name="dashed-name" />
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<svelte:options customElement="my-element" />
2+
3+
<button><slot /></button>
4+
5+
{#if foo}
6+
<slot name="foo" {foo} />
7+
{/if}
8+
9+
{#if bar}
10+
{$$slots}
11+
<slot name="bar" />
12+
{/if}
13+
14+
{#if children}foo{/if}
15+
16+
<slot name="dashed-name" />

0 commit comments

Comments
 (0)