diff --git a/src/runtime/internal/await_block.ts b/src/runtime/internal/await_block.ts index 4037caa98e..6cd7ee5cb4 100644 --- a/src/runtime/internal/await_block.ts +++ b/src/runtime/internal/await_block.ts @@ -14,6 +14,8 @@ export function handle_promise(promise, info) { const child_ctx = assign(assign({}, info.ctx), info.resolved); const block = type && (info.current = type)(child_ctx); + let needs_flush = false; + if (info.block) { if (info.blocks) { info.blocks.forEach((block, i) => { @@ -33,11 +35,15 @@ export function handle_promise(promise, info) { transition_in(block, 1); block.m(info.mount(), info.anchor); - flush(); + needs_flush = true; } info.block = block; if (info.blocks) info.blocks[index] = block; + + if (needs_flush) { + flush(); + } } if (is_promise(promise)) { diff --git a/test/runtime/samples/await-set-simultaneous-reactive/_config.js b/test/runtime/samples/await-set-simultaneous-reactive/_config.js new file mode 100644 index 0000000000..a591bf424f --- /dev/null +++ b/test/runtime/samples/await-set-simultaneous-reactive/_config.js @@ -0,0 +1,13 @@ +export default { + html: `

wait for it...

`, + test({ assert, component, target }) { + + return component.promise + .then(() => { + assert.htmlEqual(target.innerHTML, ` +

the answer is 42!

+

the answer100 is 4200!

+ `); + }); + } +}; \ No newline at end of file diff --git a/test/runtime/samples/await-set-simultaneous-reactive/main.svelte b/test/runtime/samples/await-set-simultaneous-reactive/main.svelte new file mode 100644 index 0000000000..c1bbac66be --- /dev/null +++ b/test/runtime/samples/await-set-simultaneous-reactive/main.svelte @@ -0,0 +1,21 @@ + + +{#if promise} + {#await promise} +

wait for it...

+ {:then _} +

the answer is {answer}!

+

the answer100 is {answer100}!

+ {:catch error} +

well that's odd

+ {/await} +{/if} \ No newline at end of file