also fix snippet block, fixes #16811

pull/16817/head
Simon Holthausen 2 days ago
parent 539af17112
commit c3d4221ad7

@ -3,6 +3,7 @@
/** @import { ComponentContext } from '../types.js' */
import { dev } from '../../../../state.js';
import * as b from '#compiler/builders';
import { create_async_block } from './shared/utils.js';
/**
* @param {AST.SnippetBlock} node
@ -15,6 +16,10 @@ export function SnippetBlock(node, context) {
/** @type {BlockStatement} */ (context.visit(node.body))
);
if (node.body.metadata.has_await) {
fn.body = b.block([create_async_block(fn.body)]);
}
// @ts-expect-error - TODO remove this hack once $$render_inner for legacy bindings is gone
fn.___snippet = true;

@ -0,0 +1,6 @@
{#snippet foo()}
{@const x = await 'this should work'}
<div>{x}</div>
{/snippet}
{@render foo()}
Loading…
Cancel
Save