Skip to content

Commit a17dc3c

Browse files
fix: correctly migrate named self closing slots (#17199)
1 parent 1101810 commit a17dc3c

File tree

4 files changed

+18
-3
lines changed

4 files changed

+18
-3
lines changed

.changeset/fuzzy-fans-hammer.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: correctly migrate named self closing slots

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1058,17 +1058,19 @@ const template = {
10581058
handle_identifier(node, state, path);
10591059
},
10601060
RegularElement(node, { state, path, next }) {
1061-
migrate_slot_usage(node, path, state);
1062-
handle_events(node, state);
10631061
// Strip off any namespace from the beginning of the node name.
10641062
const node_name = node.name.replace(/[a-zA-Z-]*:/g, '');
10651063

10661064
if (state.analysis.source[node.end - 2] === '/' && !is_void(node_name) && !is_svg(node_name)) {
10671065
let trimmed_position = node.end - 2;
10681066
while (state.str.original.charAt(trimmed_position - 1) === ' ') trimmed_position--;
10691067
state.str.remove(trimmed_position, node.end - 1);
1070-
state.str.appendRight(node.end, `</${node.name}>`);
1068+
state.str.appendLeft(node.end, `</${node.name}>`);
10711069
}
1070+
1071+
migrate_slot_usage(node, path, state);
1072+
handle_events(node, state);
1073+
10721074
next();
10731075
},
10741076
SvelteSelf(node, { state, next }) {
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<Component>
2+
<div slot="test" />
3+
</Component>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<Component>
2+
{#snippet test()}
3+
<div ></div>
4+
{/snippet}
5+
</Component>

0 commit comments

Comments
 (0)