diff --git a/.changeset/tidy-buses-whisper.md b/.changeset/tidy-buses-whisper.md new file mode 100644 index 0000000000..eaf2950165 --- /dev/null +++ b/.changeset/tidy-buses-whisper.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +fix: transform `{@render ...}` expression diff --git a/packages/svelte/src/compiler/phases/3-transform/server/transform-server.js b/packages/svelte/src/compiler/phases/3-transform/server/transform-server.js index e5fcdd415d..f00091a20b 100644 --- a/packages/svelte/src/compiler/phases/3-transform/server/transform-server.js +++ b/packages/svelte/src/compiler/phases/3-transform/server/transform-server.js @@ -1120,9 +1120,10 @@ const template_visitors = { state.init.push(anchor); state.template.push(t_expression(anchor_id)); + const expression = /** @type {import('estree').Expression} */ (context.visit(node.expression)); const snippet_function = state.options.dev - ? b.call('$.validate_snippet', node.expression) - : node.expression; + ? b.call('$.validate_snippet', expression) + : expression; if (node.argument) { state.template.push( t_statement( diff --git a/packages/svelte/tests/runtime-runes/samples/snippet-store/_config.js b/packages/svelte/tests/runtime-runes/samples/snippet-store/_config.js new file mode 100644 index 0000000000..33e7def9f1 --- /dev/null +++ b/packages/svelte/tests/runtime-runes/samples/snippet-store/_config.js @@ -0,0 +1,5 @@ +import { test } from '../../test'; + +export default test({ + html: `

hello world

` +}); diff --git a/packages/svelte/tests/runtime-runes/samples/snippet-store/main.svelte b/packages/svelte/tests/runtime-runes/samples/snippet-store/main.svelte new file mode 100644 index 0000000000..bf84fc2f67 --- /dev/null +++ b/packages/svelte/tests/runtime-runes/samples/snippet-store/main.svelte @@ -0,0 +1,11 @@ + + +{#snippet hello()} +

hello world

+{/snippet} + +{@render $snippet()}