diff --git a/src/shared/keyed-each.js b/src/shared/keyed-each.js index 591da14b17..1e5c15f81a 100644 --- a/src/shared/keyed-each.js +++ b/src/shared/keyed-each.js @@ -49,8 +49,8 @@ export function updateKeyedEach(old_blocks, component, changed, get_key, dynamic var will_move = {}; var did_move = {}; - function insert(block, removeFirst) { - if (removeFirst && block.o) block.o(noop); + function insert(block) { + if (lookup[block.key] && block.o) block.o(noop); block[intro_method](node, next); lookup[block.key] = block; next = block.first; @@ -77,7 +77,7 @@ export function updateKeyedEach(old_blocks, component, changed, get_key, dynamic } else if (!lookup[new_key] || will_move[new_key]) { - insert(new_block, !!lookup[new_key]); + insert(new_block); } else if (did_move[old_key]) { @@ -85,7 +85,7 @@ export function updateKeyedEach(old_blocks, component, changed, get_key, dynamic } else if (deltas[new_key] > deltas[old_key]) { did_move[new_key] = true; - insert(new_block, true); + insert(new_block); } else { will_move[old_key] = true; diff --git a/test/js/samples/each-block-keyed-animated/expected-bundle.js b/test/js/samples/each-block-keyed-animated/expected-bundle.js index ec3d717d9b..74982be2bf 100644 --- a/test/js/samples/each-block-keyed-animated/expected-bundle.js +++ b/test/js/samples/each-block-keyed-animated/expected-bundle.js @@ -291,8 +291,8 @@ function updateKeyedEach(old_blocks, component, changed, get_key, dynamic, ctx, var will_move = {}; var did_move = {}; - function insert(block, removeFirst) { - if (removeFirst && block.o) block.o(noop); + function insert(block) { + if (lookup[block.key] && block.o) block.o(noop); block[intro_method](node, next); lookup[block.key] = block; next = block.first; @@ -319,7 +319,7 @@ function updateKeyedEach(old_blocks, component, changed, get_key, dynamic, ctx, } else if (!lookup[new_key] || will_move[new_key]) { - insert(new_block, !!lookup[new_key]); + insert(new_block); } else if (did_move[old_key]) { @@ -327,7 +327,7 @@ function updateKeyedEach(old_blocks, component, changed, get_key, dynamic, ctx, } else if (deltas[new_key] > deltas[old_key]) { did_move[new_key] = true; - insert(new_block, true); + insert(new_block); } else { will_move[old_key] = true; diff --git a/test/js/samples/each-block-keyed/expected-bundle.js b/test/js/samples/each-block-keyed/expected-bundle.js index ec3aff8e03..d5695d673b 100644 --- a/test/js/samples/each-block-keyed/expected-bundle.js +++ b/test/js/samples/each-block-keyed/expected-bundle.js @@ -71,8 +71,8 @@ function updateKeyedEach(old_blocks, component, changed, get_key, dynamic, ctx, var will_move = {}; var did_move = {}; - function insert(block, removeFirst) { - if (removeFirst && block.o) block.o(noop); + function insert(block) { + if (lookup[block.key] && block.o) block.o(noop); block[intro_method](node, next); lookup[block.key] = block; next = block.first; @@ -99,7 +99,7 @@ function updateKeyedEach(old_blocks, component, changed, get_key, dynamic, ctx, } else if (!lookup[new_key] || will_move[new_key]) { - insert(new_block, !!lookup[new_key]); + insert(new_block); } else if (did_move[old_key]) { @@ -107,7 +107,7 @@ function updateKeyedEach(old_blocks, component, changed, get_key, dynamic, ctx, } else if (deltas[new_key] > deltas[old_key]) { did_move[new_key] = true; - insert(new_block, true); + insert(new_block); } else { will_move[old_key] = true;