diff --git a/src/compiler/compile/render_dom/wrappers/AwaitBlock.ts b/src/compiler/compile/render_dom/wrappers/AwaitBlock.ts index 2bdc31948d44..2038943d8bbc 100644 --- a/src/compiler/compile/render_dom/wrappers/AwaitBlock.ts +++ b/src/compiler/compile/render_dom/wrappers/AwaitBlock.ts @@ -96,7 +96,7 @@ class AwaitBlockBranch extends Wrapper { `); this.block.chunks.declarations.push(b`${get_context}(#ctx)`); if (this.block.has_update_method) { - this.block.chunks.update.push(b`${get_context}(#ctx)`); + this.block.chunks.update.unshift(b`${get_context}(#ctx)`); } } } diff --git a/test/runtime/samples/await-then-destruct-object-if/_config.js b/test/runtime/samples/await-then-destruct-object-if/_config.js new file mode 100644 index 000000000000..6a29b2db3748 --- /dev/null +++ b/test/runtime/samples/await-then-destruct-object-if/_config.js @@ -0,0 +1,29 @@ +export default { + props: { + thePromise: Promise.resolve({ result: 1 }) + }, + + html: '', + + async test({ assert, component, target }) { + await (component.thePromise = Promise.resolve({ result: 1 })); + + assert.htmlEqual( + target.innerHTML, + ` +
result: 1
+count: 0
+ ` + ); + + await new Promise(resolve => setTimeout(resolve, 1)); + + assert.htmlEqual( + target.innerHTML, + ` +result: 1
+count: 1
+ ` + ); + } +}; diff --git a/test/runtime/samples/await-then-destruct-object-if/main.svelte b/test/runtime/samples/await-then-destruct-object-if/main.svelte new file mode 100644 index 000000000000..3425979e2c8b --- /dev/null +++ b/test/runtime/samples/await-then-destruct-object-if/main.svelte @@ -0,0 +1,19 @@ + + +{#await thePromise then { result }} + {#if result} +result: {result}
+count: {count}
+ {:else} +result: {result}
+count: {count}
+ {/if} +{/await}