Skip to content

Commit 5c784e2

Browse files
committed
add failing test
1 parent 6cd4258 commit 5c784e2

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,13 @@ export function SvelteBoundary(node, context) {
6969
if (node.fragment.metadata.has_await) {
7070
// we have to make sure the `$.suspend` goes before everything else
7171
snippet_fn.body.body.splice(
72-
dev ? 2 : 1,
72+
dev ? 3 : 2,
7373
0,
7474
...const_tags.filter((node) => node.type === 'VariableDeclaration')
7575
);
7676
} else {
7777
snippet_fn.body.body.splice(
78-
dev ? 1 : 0,
78+
dev ? 2 : 1,
7979
0,
8080
...const_tags.filter((node) => node.type === 'VariableDeclaration')
8181
);

packages/svelte/tests/runtime-runes/samples/async-const/_config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ export default test({
77
async test({ assert, target }) {
88
await tick();
99

10-
assert.htmlEqual(target.innerHTML, `<h1>Hello, world!</h1>`);
10+
assert.htmlEqual(target.innerHTML, `<h1>Hello, world!</h1> 5 01234`);
1111
}
1212
});

packages/svelte/tests/runtime-runes/samples/async-const/main.svelte

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,21 @@
33
</script>
44

55
<svelte:boundary>
6+
{@const number = await Promise.resolve(5)}
67
{#snippet pending()}
78
<h1>Loading...</h1>
89
{/snippet}
910

1011
{#snippet greet()}
1112
{@const greeting = await `Hello, ${name}!`}
1213
<h1>{greeting}</h1>
14+
{number}
15+
{#if number > 4}
16+
{#each { length: number }, index}
17+
{@const i = await index}
18+
{i}
19+
{/each}
20+
{/if}
1321
{/snippet}
1422

1523
{@render greet()}

0 commit comments

Comments
 (0)