0
0
mirror of https://github.com/sveltejs/svelte.git synced 2024-12-01 17:30:59 +01:00

Fixes keyed each blocks for outro

Fixes #1706
This commit is contained in:
Jacob Wright 2018-08-29 09:52:43 -06:00 committed by Conduitry
parent 2e4b65af5a
commit 67d4d60c3a
4 changed files with 26 additions and 1 deletions

View File

@ -331,7 +331,7 @@ export default class EachBlock extends Node {
${this.block.hasAnimation && `for (let #i = 0; #i < ${blocks}.length; #i += 1) ${blocks}[#i].a();`} ${this.block.hasAnimation && `for (let #i = 0; #i < ${blocks}.length; #i += 1) ${blocks}[#i].a();`}
`); `);
if (this.compiler.options.nestedTransitions) { if (this.block.hasOutros && this.compiler.options.nestedTransitions) {
const countdown = block.getUniqueName('countdown'); const countdown = block.getUniqueName('countdown');
block.builders.outro.addBlock(deindent` block.builders.outro.addBlock(deindent`
const ${countdown} = @callAfter(#outrocallback, ${blocks}.length); const ${countdown} = @callAfter(#outrocallback, ${blocks}.length);

View File

@ -0,0 +1,3 @@
{#each things as thing (thing)}
<div></div>
{/each}

View File

@ -0,0 +1,13 @@
export default {
nestedTransitions: true,
data: {
x: true,
things: ['a', 'b']
},
test(assert, component, target, window, raf) {
component.set({ x: false });
assert.htmlEqual(target.innerHTML, '');
},
};

View File

@ -0,0 +1,9 @@
{#if x}
<Widget :things/>
{/if}
<script>
export default {
components: { Widget: './Widget.html' }
};
</script>