diff --git a/src/compile/nodes/EachBlock.ts b/src/compile/nodes/EachBlock.ts index 720161971d..89953ca19a 100644 --- a/src/compile/nodes/EachBlock.ts +++ b/src/compile/nodes/EachBlock.ts @@ -393,14 +393,16 @@ export default class EachBlock extends Node { allDependencies.add(dependency); }); - const outro = this.block.hasOutros && block.getUniqueName('outro') - if (outro) { + const outroBlock = this.block.hasOutros && block.getUniqueName('outroBlock') + if (outroBlock) { block.builders.init.addBlock(deindent` - function ${outro}(i, detach, fn) { + function ${outroBlock}(i, detach, fn) { if (${iterations}[i]) { ${iterations}[i].o(() => { - ${iterations}[i].d(detach); - if (detach) ${iterations}[i] = null; + if (detach) { + ${iterations}[i].d(detach); + ${iterations}[i] = null; + } if (fn) fn(); }); } @@ -447,7 +449,7 @@ export default class EachBlock extends Node { if (this.block.hasOutros) { destroy = deindent` @transitionManager.groupOutros(); - for (; #i < ${iterations}.length; #i += 1) ${outro}(#i, 1); + for (; #i < ${iterations}.length; #i += 1) ${outroBlock}(#i, 1); `; } else { destroy = deindent` @@ -473,10 +475,10 @@ export default class EachBlock extends Node { `); } - if (outro && this.compiler.options.nestedTransitions) { + if (outroBlock && this.compiler.options.nestedTransitions) { block.builders.outro.addBlock(deindent` #outrocallback = @callAfter(#outrocallback, #i); - for (let #i = 0; #i < ${iterations}.length; #i += 1) ${outro}(#i, 0, #outrocallback);` + for (let #i = 0; #i < ${iterations}.length; #i += 1) ${outroBlock}(#i, 0, #outrocallback);` ); }