fix: transform `{@render ...}` expression (#10116)

fixes #10059
pull/10112/head
Simon H 12 months ago committed by GitHub
parent 05789daff9
commit 527d099a09
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,5 @@
---
'svelte': patch
---
fix: transform `{@render ...}` expression

@ -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(

@ -0,0 +1,5 @@
import { test } from '../../test';
export default test({
html: `<p>hello world</p>`
});

@ -0,0 +1,11 @@
<script>
import { writable } from 'svelte/store';
let snippet = writable(hello);
</script>
{#snippet hello()}
<p>hello world</p>
{/snippet}
{@render $snippet()}
Loading…
Cancel
Save