pull/4699/head
pushkine 6 years ago
parent cffeb65a82
commit 94c14c4a3d

@ -520,51 +520,36 @@ export default class IfBlockWrapper extends Wrapper {
if (branch.dependencies.length > 0) { if (branch.dependencies.length > 0) {
const update_mount_node = this.get_update_mount_node(anchor); const update_mount_node = this.get_update_mount_node(anchor);
const enter = b` if (branch.snippet) {
block.chunks.update.push(
b`if (${block.renderer.dirty(branch.dependencies)}) ${
branch.condition
} = ${branch.snippet}`
);
}
const outro =
branch.block.has_outro_method &&
b`@group_outros();
@transition_out(${name}, 1, 1, () => { ${name} = null; });
@check_outros();`;
block.chunks.update.push(b`
if (${name}) { if (${name}) {
${dynamic && b`${name}.p(#ctx, #dirty);`}
if (${branch.condition}) {
${ ${
has_transitions && has_transitions &&
b`if (${block.renderer.dirty(branch.dependencies)}) { b`if (${block.renderer.dirty(branch.dependencies)}) {
@transition_in(${name}, 1); @transition_in(${name}, 1);
}` }`
} }
${dynamic && b`${name}.p(#ctx, #dirty);`} } else {${outro ? outro : b`${name}.d(1);${name} = null;`}}
} else { } else {
${name} = ${branch.block.name}(#ctx); ${name} = ${branch.block.name}(#ctx);
${name}.c(); ${name}.c();
${has_transitions && b`@transition_in(${name}, 1);`} ${has_transitions && b`@transition_in(${name}, 1);`}
${name}.m(${update_mount_node}, ${anchor}); ${name}.m(${update_mount_node}, ${anchor});
} }`);
`;
if (branch.snippet) {
block.chunks.update.push(b`if (${block.renderer.dirty(branch.dependencies)}) ${branch.condition} = ${branch.snippet}`);
}
// no `p()` here — we don't want to update outroing nodes,
// as that will typically result in glitching
if (branch.block.has_outro_method) {
block.chunks.update.push(b`
if (${branch.condition}) {
${enter}
} else if (${name}) {
@group_outros();
@transition_out(${name}, 1, 1, () => {
${name} = null;
});
@check_outros();
}
`);
} else {
block.chunks.update.push(b`
if (${branch.condition}) {
${enter}
} else if (${name}) {
${name}.d(1);
${name} = null;
}
`);
}
} else if (dynamic) { } else if (dynamic) {
block.chunks.update.push(b` block.chunks.update.push(b`
if (${branch.condition}) ${name}.p(#ctx, #dirty); if (${branch.condition}) ${name}.p(#ctx, #dirty);

Loading…
Cancel
Save