File tree 4 files changed +47
-1
lines changed
tests/migrate/samples/shadowed-forwarded-slot
4 files changed +47
-1
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ ' svelte ' : patch
3
+ ---
4
+
5
+ fix: account for shadowing children slot during migration
Original file line number Diff line number Diff line change @@ -1300,6 +1300,21 @@ const template = {
1300
1300
existing_prop . needs_refine_type = false ;
1301
1301
}
1302
1302
1303
+ if (
1304
+ slot_name === 'default' &&
1305
+ path . some (
1306
+ ( parent ) =>
1307
+ ( parent . type === 'SvelteComponent' ||
1308
+ parent . type === 'Component' ||
1309
+ parent . type === 'RegularElement' ||
1310
+ parent . type === 'SvelteElement' ||
1311
+ parent . type === 'SvelteFragment' ) &&
1312
+ parent . attributes . some ( ( attr ) => ( attr . type = 'LetDirective' ) )
1313
+ )
1314
+ ) {
1315
+ aliased_slot_name = `${ name } _render` ;
1316
+ state . derived_conflicting_slots . set ( aliased_slot_name , name ) ;
1317
+ }
1303
1318
name = aliased_slot_name ?? name ;
1304
1319
1305
1320
if ( node . fragment . nodes . length > 0 ) {
Original file line number Diff line number Diff line change 12
12
</div >
13
13
</MyComponent >
14
14
</div >
15
+ </MyInput >
16
+
17
+ <MyInput let:args >
18
+ <slot />
19
+ </MyInput >
20
+
21
+ <MyInput >
22
+ <div let:args >
23
+ <slot />
24
+ </div >
15
25
</MyInput >
Original file line number Diff line number Diff line change 2
2
/**
3
3
* @typedef {Object} Props
4
4
* @property {import('svelte').Snippet} [label]
5
+ * @property {import('svelte').Snippet} [children]
5
6
*/
6
7
7
8
/** @type {Props} */
8
- let { label } = $props ();
9
+ let { label, children } = $props ();
9
10
const label_render = $derived (label);
11
+ const children_render = $derived (children);
10
12
11
13
</script >
12
14
30
32
</MyComponent >
31
33
</div >
32
34
{/ snippet }
35
+ </MyInput >
36
+
37
+ <MyInput >
38
+ {#snippet children ({ args })}
39
+ {@render children_render ?.()}
40
+ {/ snippet }
41
+ </MyInput >
42
+
43
+ <MyInput >
44
+ <div >
45
+ {#snippet children ({ args })}
46
+ {@render children_render ?.()}
47
+ {/ snippet }
48
+ </div >
33
49
</MyInput >
You can’t perform that action at this time.
0 commit comments