From 32f43b125bd0900bbdd55948948d659cd2a84f2e Mon Sep 17 00:00:00 2001 From: Conduitry Date: Sat, 30 Nov 2019 15:18:29 -0500 Subject: [PATCH] fix child context in await blocks with no `then` variable (#4022) --- .../compile/render_dom/wrappers/AwaitBlock.ts | 4 ++-- .../samples/await-then-no-context/main.svelte | 12 ++++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 test/runtime/samples/await-then-no-context/main.svelte diff --git a/src/compiler/compile/render_dom/wrappers/AwaitBlock.ts b/src/compiler/compile/render_dom/wrappers/AwaitBlock.ts index 8ce7495fd7..01153b1083 100644 --- a/src/compiler/compile/render_dom/wrappers/AwaitBlock.ts +++ b/src/compiler/compile/render_dom/wrappers/AwaitBlock.ts @@ -206,7 +206,7 @@ export default class AwaitBlockWrapper extends Wrapper { } else { const #child_ctx = #ctx.slice(); - #child_ctx[${value_index}] = ${info}.resolved; + ${this.node.value && x`#child_ctx[${value_index}] = ${info}.resolved;`} ${info}.block.p(#child_ctx, #dirty); } `); @@ -220,7 +220,7 @@ export default class AwaitBlockWrapper extends Wrapper { block.chunks.update.push(b` { const #child_ctx = #ctx.slice(); - #child_ctx[${value_index}] = ${info}.resolved; + ${this.node.value && x`#child_ctx[${value_index}] = ${info}.resolved;`} ${info}.block.p(#child_ctx, #dirty); } `); diff --git a/test/runtime/samples/await-then-no-context/main.svelte b/test/runtime/samples/await-then-no-context/main.svelte new file mode 100644 index 0000000000..c729512149 --- /dev/null +++ b/test/runtime/samples/await-then-no-context/main.svelte @@ -0,0 +1,12 @@ + + +{#await promise} +
waiting
+{:then} + {#each test as t} +
t
+ {/each} +{/await}