fix transitions on each else block

pull/5179/head
Carlos Edinson Roso Espinosa 5 years ago
parent fb8bab8164
commit 3580665195

@ -298,6 +298,22 @@ export default class EachBlockWrapper extends Wrapper {
} }
`); `);
const has_transitions = !!(this.else.block.has_intro_method || this.else.block.has_outro_method);
const destroy_block_else = this.else.block.has_outro_method
?
b`
@group_outros();
@transition_out(${each_block_else}, 1, 1, () => {
${each_block_else} = null;
});
@check_outros();
`
: b`
${each_block_else}.d(1);
${each_block_else} = null;
`;
if (this.else.block.has_update_method) { if (this.else.block.has_update_method) {
this.updates.push(b` this.updates.push(b`
if (!${this.vars.data_length} && ${each_block_else}) { if (!${this.vars.data_length} && ${each_block_else}) {
@ -305,22 +321,23 @@ export default class EachBlockWrapper extends Wrapper {
} else if (!${this.vars.data_length}) { } else if (!${this.vars.data_length}) {
${each_block_else} = ${this.else.block.name}(#ctx); ${each_block_else} = ${this.else.block.name}(#ctx);
${each_block_else}.c(); ${each_block_else}.c();
${has_transitions && b`@transition_in(${each_block_else}, 1);`}
${each_block_else}.m(${update_mount_node}, ${update_anchor_node}); ${each_block_else}.m(${update_mount_node}, ${update_anchor_node});
} else if (${each_block_else}) { } else if (${each_block_else}) {
${each_block_else}.d(1); ${destroy_block_else};
${each_block_else} = null;
} }
`); `);
} else { } else {
this.updates.push(b` this.updates.push(b`
if (${this.vars.data_length}) { if (${this.vars.data_length}) {
if (${each_block_else}) { if (${each_block_else}) {
${each_block_else}.d(1); ${destroy_block_else};
${each_block_else} = null;
} }
} else if (!${each_block_else}) { } else if (!${each_block_else}) {
${each_block_else} = ${this.else.block.name}(#ctx); ${each_block_else} = ${this.else.block.name}(#ctx);
${each_block_else}.c(); ${each_block_else}.c();
${has_transitions && b`@transition_in(${each_block_else}, 1);`}
${each_block_else}.m(${update_mount_node}, ${update_anchor_node}); ${each_block_else}.m(${update_mount_node}, ${update_anchor_node});
} }
`); `);

Loading…
Cancel
Save