diff --git a/src/compiler/compile/render_dom/wrappers/AwaitBlock.ts b/src/compiler/compile/render_dom/wrappers/AwaitBlock.ts index 01153b1083..25c5312e65 100644 --- a/src/compiler/compile/render_dom/wrappers/AwaitBlock.ts +++ b/src/compiler/compile/render_dom/wrappers/AwaitBlock.ts @@ -71,6 +71,8 @@ export default class AwaitBlockWrapper extends Wrapper { this.not_static_content(); block.add_dependencies(this.node.expression.dependencies); + if (this.node.value) block.renderer.add_to_context(this.node.value, true); + if (this.node.error) block.renderer.add_to_context(this.node.error, true); let is_dynamic = false; let has_intros = false; @@ -118,9 +120,6 @@ export default class AwaitBlockWrapper extends Wrapper { if (has_outros) { block.add_outro(); } - - if (this.node.value) block.renderer.add_to_context(this.node.value, true); - if (this.node.error) block.renderer.add_to_context(this.node.error, true); } render( diff --git a/test/runtime/samples/await-then-if/_config.js b/test/runtime/samples/await-then-if/_config.js new file mode 100644 index 0000000000..b26688d9f3 --- /dev/null +++ b/test/runtime/samples/await-then-if/_config.js @@ -0,0 +1,25 @@ +let fulfil; + +const thePromise = new Promise(f => { + fulfil = f; +}); + +export default { + props: { + thePromise + }, + + html: ` + loading... + `, + + async test({ assert, component, target }) { + fulfil([]); + + await thePromise; + + assert.htmlEqual(target.innerHTML, ` +
promise array is empty
+ `); + } +}; \ No newline at end of file diff --git a/test/runtime/samples/await-then-if/main.svelte b/test/runtime/samples/await-then-if/main.svelte new file mode 100644 index 0000000000..d292067b30 --- /dev/null +++ b/test/runtime/samples/await-then-if/main.svelte @@ -0,0 +1,13 @@ + + +{#await thePromise} + loading... +{:then r} + {#if r.length < 1} +promise array is empty
+ {:else} +promise array is not empty
+ {/if} +{/await} \ No newline at end of file