Skip to content

Commit b5a6376

Browse files
committed
tweak
1 parent 31d6ba9 commit b5a6376

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1193,17 +1193,18 @@ function migrate_slot_usage(node, path, state) {
11931193
);
11941194
}
11951195
} else {
1196-
const prepend_string = `{#snippet ${snippet_name}(${props})}\n${state.indent.repeat(path.length - 2)}`;
11971196
// Named slot or `svelte:fragment`: wrap element itself in a snippet
1198-
state.str.prependLeft(node.start, prepend_string);
1197+
state.str.prependLeft(
1198+
node.start,
1199+
`{#snippet ${snippet_name}(${props})}\n${state.indent.repeat(path.length - 2)}`
1200+
);
11991201
state.str.indent(state.indent, {
12001202
exclude: [
12011203
[0, node.start],
12021204
[node.end, state.str.original.length]
12031205
]
12041206
});
1205-
const append_string = `\n${state.indent.repeat(path.length - 2)}{/snippet}`;
1206-
state.str.appendLeft(node.end, append_string);
1207+
state.str.appendRight(node.end, `\n${state.indent.repeat(path.length - 2)}{/snippet}`);
12071208
}
12081209
}
12091210

packages/svelte/tests/migrate/samples/named-slots/output.svelte

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,5 @@
1010
<Component>
1111
{#snippet msg()}
1212
{@render children?.()}
13+
{/snippet}
1314
</Component>

0 commit comments

Comments
 (0)