From 50f10fabc2c6e2113ac7c981d83958f14f0f3223 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Fri, 25 May 2018 16:34:34 -0400 Subject: [PATCH] fix #1497 --- src/compile/nodes/EachBlock.ts | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) 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);` ); }