Skip to content

Commit 7f8e60f

Browse files
fix: generate correct SSR code for the case where pending is an attribute (#16919)
Closes #16886
1 parent 9c350cf commit 7f8e60f

File tree

5 files changed

+22
-2
lines changed

5 files changed

+22
-2
lines changed

.changeset/spicy-rabbits-drive.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: generate correct SSR code for the case where `pending` is an attribute

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,14 @@ export function SvelteBoundary(node, context) {
4343
);
4444
const pending = b.call(callee, b.id('$$renderer'));
4545
const block = /** @type {BlockStatement} */ (context.visit(node.fragment));
46+
const statement = node.fragment.metadata.has_await
47+
? create_async_block(b.block([block]))
48+
: block;
4649
context.state.template.push(
4750
b.if(
4851
callee,
49-
b.block(build_template([block_open_else, pending, block_close])),
50-
b.block(build_template([block_open, block, block_close]))
52+
b.block([b.stmt(pending)]),
53+
b.block(build_template([block_open, statement, block_close]))
5154
)
5255
);
5356
} else {
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import { test } from '../../test';
2+
3+
export default test({});
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<!--[--><!---->Loading...<!--]-->
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{#snippet pending()}
2+
Loading...
3+
{/snippet}
4+
5+
<svelte:boundary pending={pending}>
6+
{@const data = await Promise.resolve('hello')}
7+
<p>{data}</p>
8+
</svelte:boundary>

0 commit comments

Comments
 (0)