fix: correctly migrate named self closing slots

named-self-closing-slot
paoloricciuti 20 hours ago
parent 9ccbd734f2
commit 87818df16d

@ -0,0 +1,5 @@
---
'svelte': patch
---
fix: correctly migrate named self closing slots

@ -1058,8 +1058,6 @@ const template = {
handle_identifier(node, state, path); handle_identifier(node, state, path);
}, },
RegularElement(node, { state, path, next }) { RegularElement(node, { state, path, next }) {
migrate_slot_usage(node, path, state);
handle_events(node, state);
// Strip off any namespace from the beginning of the node name. // Strip off any namespace from the beginning of the node name.
const node_name = node.name.replace(/[a-zA-Z-]*:/g, ''); const node_name = node.name.replace(/[a-zA-Z-]*:/g, '');
@ -1067,8 +1065,12 @@ const template = {
let trimmed_position = node.end - 2; let trimmed_position = node.end - 2;
while (state.str.original.charAt(trimmed_position - 1) === ' ') trimmed_position--; while (state.str.original.charAt(trimmed_position - 1) === ' ') trimmed_position--;
state.str.remove(trimmed_position, node.end - 1); state.str.remove(trimmed_position, node.end - 1);
state.str.appendRight(node.end, `</${node.name}>`); state.str.appendLeft(node.end, `</${node.name}>`);
} }
migrate_slot_usage(node, path, state);
handle_events(node, state);
next(); next();
}, },
SvelteSelf(node, { state, next }) { SvelteSelf(node, { state, next }) {

@ -0,0 +1,3 @@
<Component>
<div slot="test" />
</Component>

@ -0,0 +1,5 @@
<Component>
{#snippet test()}
<div ></div>
{/snippet}
</Component>
Loading…
Cancel
Save