From 4d47d2176bec8ef31c23487ae1ac8abe03094418 Mon Sep 17 00:00:00 2001 From: Harald Fassler Date: Thu, 30 May 2019 17:54:18 +0200 Subject: [PATCH] fix #2908 --- src/compiler/compile/render-dom/wrappers/EachBlock.ts | 4 +++- src/runtime/internal/keyed-each.ts | 5 +++++ test/js/samples/each-block-keyed-animated/expected.js | 4 ++-- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/compiler/compile/render-dom/wrappers/EachBlock.ts b/src/compiler/compile/render-dom/wrappers/EachBlock.ts index 9208c838ad..b2dd5a7508 100644 --- a/src/compiler/compile/render-dom/wrappers/EachBlock.ts +++ b/src/compiler/compile/render-dom/wrappers/EachBlock.ts @@ -343,7 +343,9 @@ export default class EachBlockWrapper extends Wrapper { const dynamic = this.block.has_update_method; const destroy = this.node.has_animation - ? `@fix_and_outro_and_destroy_block` + ? (this.block.has_outros + ? `@fix_and_outro_and_destroy_block` + : `@fix_and_destroy_block`) : this.block.has_outros ? `@outro_and_destroy_block` : `@destroy_block`; diff --git a/src/runtime/internal/keyed-each.ts b/src/runtime/internal/keyed-each.ts index 0ec8b09400..f13c858897 100644 --- a/src/runtime/internal/keyed-each.ts +++ b/src/runtime/internal/keyed-each.ts @@ -13,6 +13,11 @@ export function outro_and_destroy_block(block, lookup) { block.o(1); } +export function fix_and_destroy_block(block, lookup) { + block.f(); + destroy_block(block, lookup); +} + export function fix_and_outro_and_destroy_block(block, lookup) { block.f(); outro_and_destroy_block(block, lookup); diff --git a/test/js/samples/each-block-keyed-animated/expected.js b/test/js/samples/each-block-keyed-animated/expected.js index d18c569fa1..ec28e60d5f 100644 --- a/test/js/samples/each-block-keyed-animated/expected.js +++ b/test/js/samples/each-block-keyed-animated/expected.js @@ -6,7 +6,7 @@ import { detach, element, empty, - fix_and_outro_and_destroy_block, + fix_and_destroy_block, fix_position, init, insert, @@ -100,7 +100,7 @@ function create_fragment(ctx) { p(changed, ctx) { const each_value = ctx.things; for (let i = 0; i < each_blocks.length; i += 1) each_blocks[i].r(); - each_blocks = update_keyed_each(each_blocks, changed, get_key, 1, ctx, each_value, each_1_lookup, each_1_anchor.parentNode, fix_and_outro_and_destroy_block, create_each_block, each_1_anchor, get_each_context); + each_blocks = update_keyed_each(each_blocks, changed, get_key, 1, ctx, each_value, each_1_lookup, each_1_anchor.parentNode, fix_and_destroy_block, create_each_block, each_1_anchor, get_each_context); for (let i = 0; i < each_blocks.length; i += 1) each_blocks[i].a(); },