Skip to content

Commit

Permalink
fix #1497
Browse files Browse the repository at this point in the history
  • Loading branch information
Rich-Harris committed May 25, 2018
1 parent 058f7ea commit ac7f591
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/compile/nodes/EachBlock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
}
Expand Down Expand Up @@ -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`
Expand All @@ -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);`
);
}

Expand Down

0 comments on commit ac7f591

Please sign in to comment.