pull/1498/head
Rich Harris 7 years ago
parent 058f7ea43a
commit ac7f591f60

@ -393,14 +393,16 @@ export default class EachBlock extends Node {
allDependencies.add(dependency); allDependencies.add(dependency);
}); });
const outro = this.block.hasOutros && block.getUniqueName('outro') const outroBlock = this.block.hasOutros && block.getUniqueName('outroBlock')
if (outro) { if (outroBlock) {
block.builders.init.addBlock(deindent` block.builders.init.addBlock(deindent`
function ${outro}(i, detach, fn) { function ${outroBlock}(i, detach, fn) {
if (${iterations}[i]) { if (${iterations}[i]) {
${iterations}[i].o(() => { ${iterations}[i].o(() => {
${iterations}[i].d(detach); if (detach) {
if (detach) ${iterations}[i] = null; ${iterations}[i].d(detach);
${iterations}[i] = null;
}
if (fn) fn(); if (fn) fn();
}); });
} }
@ -447,7 +449,7 @@ export default class EachBlock extends Node {
if (this.block.hasOutros) { if (this.block.hasOutros) {
destroy = deindent` destroy = deindent`
@transitionManager.groupOutros(); @transitionManager.groupOutros();
for (; #i < ${iterations}.length; #i += 1) ${outro}(#i, 1); for (; #i < ${iterations}.length; #i += 1) ${outroBlock}(#i, 1);
`; `;
} else { } else {
destroy = deindent` 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` block.builders.outro.addBlock(deindent`
#outrocallback = @callAfter(#outrocallback, #i); #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);`
); );
} }

Loading…
Cancel
Save