Skip to content

Commit

Permalink
fix child context in await blocks with no then variable (#4022)
Browse files Browse the repository at this point in the history
  • Loading branch information
Conduitry committed Dec 4, 2019
1 parent 4e51d35 commit 185ff4a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/compiler/compile/render_dom/wrappers/AwaitBlock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
`);
Expand All @@ -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);
}
`);
Expand Down
12 changes: 12 additions & 0 deletions test/runtime/samples/await-then-no-context/main.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<script>
const promise = new Promise(() => {});
const test = [1, 2, 3];
</script>

{#await promise}
<div>waiting</div>
{:then}
{#each test as t}
<div>t</div>
{/each}
{/await}

0 comments on commit 185ff4a

Please sign in to comment.