fix: allow await in svelte boundary without pending (#16857)

Fix: #16856
pull/16881/head
Yuki Ishii 2 days ago committed by GitHub
parent e9cd45a2da
commit 31541c8849
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -0,0 +1,5 @@
---
'svelte': patch
---
fix: allow await in svelte:boundary without pending

@ -2,7 +2,13 @@
/** @import { AST } from '#compiler' */
/** @import { ComponentContext } from '../types' */
import * as b from '#compiler/builders';
import { block_close, block_open, block_open_else, build_attribute_value } from './shared/utils.js';
import {
block_close,
block_open,
block_open_else,
build_attribute_value,
create_async_block
} from './shared/utils.js';
/**
* @param {AST.SvelteBoundary} node
@ -37,6 +43,9 @@ export function SvelteBoundary(node, context) {
context.state.template.push(block_open_else, pending, block_close);
} else {
const block = /** @type {BlockStatement} */ (context.visit(node.fragment));
context.state.template.push(block_open, block, block_close);
const statement = node.fragment.metadata.has_await
? create_async_block(b.block([block]))
: block;
context.state.template.push(block_open, statement, block_close);
}
}

@ -0,0 +1,4 @@
<svelte:boundary>
{@const x = await 'this should work'}
<div>{x}</div>
</svelte:boundary>
Loading…
Cancel
Save