diff --git a/src/embed.ts b/src/embed.ts index 9f55ac5..03bdaa5 100644 --- a/src/embed.ts +++ b/src/embed.ts @@ -125,16 +125,19 @@ export function embed(path: FastPath, _options: Options) { printJS(parent, false, false, true, 'expression'); break; case 'RenderTag': - // We merge the two parts into one expression, which future-proofs this for template TS support if (node === parent.expression) { - parent.expression.end = - options.originalText.indexOf( - ')', - parent.argument?.end ?? // TODO: remove at some point, snippet API changed in .next-.. - parent.arguments?.[parent.arguments.length - 1]?.end ?? - parent.expression.end, - ) + 1; - parent.argument = null; + // TODO: remove this if block at some point, snippet API changed in .next-.. + if ('argument' in parent || 'arguments' in parent) { + parent.expression.end = + options.originalText.indexOf( + ')', + parent.argument?.end ?? + parent.arguments?.[parent.arguments.length - 1]?.end ?? + parent.expression.end, + ) + 1; + parent.argument = null; + parent.arguments = null; + } printJS(parent, false, false, false, 'expression'); } break; diff --git a/test/printer/samples/snippet.html.skip b/test/printer/samples/snippet.html.skip index 4f95038..765cf60 100644 --- a/test/printer/samples/snippet.html.skip +++ b/test/printer/samples/snippet.html.skip @@ -27,6 +27,9 @@ {@render foo()} +{@render foo?.()} {@render bar(x)} +{@render bar.baz[buzz](x)} +{@render (why ? not : like ?? thiss)(x)} {@render test((() => "a")())} {@render test(t())}