move destructuring to the beginning of await block updates

pull/4627/head
Michał Zdunek 6 years ago
parent aa3dcc06d6
commit 8b88992ba9

@ -60,7 +60,7 @@ class AwaitBlockBranch extends Wrapper {
this.block.chunks.declarations.push(b`(${node.pattern} = #ctx[${index}])`); this.block.chunks.declarations.push(b`(${node.pattern} = #ctx[${index}])`);
if (this.block.has_update_method) { if (this.block.has_update_method) {
this.block.chunks.update.push(b`(${node.pattern} = #ctx[${index}])`); this.block.chunks.update.unshift(b`(${node.pattern} = #ctx[${index}])`);
} }
} }
} }

@ -0,0 +1,15 @@
export default {
async test({ assert, target, component }) {
await Promise.resolve();
component.fail = 'wrong';
assert.htmlEqual(
target.innerHTML,
`
correct
correct
`
);
}
};

@ -0,0 +1,24 @@
<script>
import { writable } from 'svelte/store';
export let fail = 'incorrect'
const object = writable(Promise.resolve({ result: true }))
const array = writable(Promise.resolve([true]))
</script>
{#await $object then { result }}
{#if result}
correct
{:else}
{fail}
{/if}
{/await}
{#await $array then [result]}
{#if result}
correct
{:else}
{fail}
{/if}
{/await}
Loading…
Cancel
Save