Skip to content

Commit 31541c8

Browse files
authored
fix: allow await in svelte boundary without pending (#16857)
Fix: #16856
1 parent e9cd45a commit 31541c8

File tree

4 files changed

+21
-2
lines changed

4 files changed

+21
-2
lines changed

.changeset/poor-flies-serve.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'svelte': patch
3+
---
4+
5+
fix: allow await in svelte:boundary without pending

packages/svelte/src/compiler/phases/3-transform/server/visitors/SvelteBoundary.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,13 @@
22
/** @import { AST } from '#compiler' */
33
/** @import { ComponentContext } from '../types' */
44
import * as b from '#compiler/builders';
5-
import { block_close, block_open, block_open_else, build_attribute_value } from './shared/utils.js';
5+
import {
6+
block_close,
7+
block_open,
8+
block_open_else,
9+
build_attribute_value,
10+
create_async_block
11+
} from './shared/utils.js';
612

713
/**
814
* @param {AST.SvelteBoundary} node
@@ -37,6 +43,9 @@ export function SvelteBoundary(node, context) {
3743
context.state.template.push(block_open_else, pending, block_close);
3844
} else {
3945
const block = /** @type {BlockStatement} */ (context.visit(node.fragment));
40-
context.state.template.push(block_open, block, block_close);
46+
const statement = node.fragment.metadata.has_await
47+
? create_async_block(b.block([block]))
48+
: block;
49+
context.state.template.push(block_open, statement, block_close);
4150
}
4251
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<div>this should work</div>
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<svelte:boundary>
2+
{@const x = await 'this should work'}
3+
<div>{x}</div>
4+
</svelte:boundary>

0 commit comments

Comments
 (0)