Skip to content

Commit c968fef

Browse files
committed
fix: adjust render tag printing for Svelte 5 AST changes
1 parent 08d7a8b commit c968fef

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

src/embed.ts

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -125,16 +125,19 @@ export function embed(path: FastPath, _options: Options) {
125125
printJS(parent, false, false, true, 'expression');
126126
break;
127127
case 'RenderTag':
128-
// We merge the two parts into one expression, which future-proofs this for template TS support
129128
if (node === parent.expression) {
130-
parent.expression.end =
131-
options.originalText.indexOf(
132-
')',
133-
parent.argument?.end ?? // TODO: remove at some point, snippet API changed in .next-..
134-
parent.arguments?.[parent.arguments.length - 1]?.end ??
135-
parent.expression.end,
136-
) + 1;
137-
parent.argument = null;
129+
// TODO: remove this if block at some point, snippet API changed in .next-..
130+
if ('argument' in parent || 'arguments' in parent) {
131+
parent.expression.end =
132+
options.originalText.indexOf(
133+
')',
134+
parent.argument?.end ??
135+
parent.arguments?.[parent.arguments.length - 1]?.end ??
136+
parent.expression.end,
137+
) + 1;
138+
parent.argument = null;
139+
parent.arguments = null;
140+
}
138141
printJS(parent, false, false, false, 'expression');
139142
}
140143
break;

test/printer/samples/snippet.html.skip

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@
2727
</div>
2828

2929
{@render foo()}
30+
{@render foo?.()}
3031
{@render bar(x)}
32+
{@render bar.baz[buzz](x)}
33+
{@render (why ? not : like ?? thiss)(x)}
3134
{@render test((() => "a")())}
3235
{@render test(t())}

0 commit comments

Comments
 (0)