|
|
|
@ -441,58 +441,58 @@ export default class IfBlockWrapper extends Wrapper {
|
|
|
|
|
`if (${name}) ${name}.m(${initial_mount_node}, ${anchor_node});`
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
const update_mount_node = this.get_update_mount_node(anchor);
|
|
|
|
|
|
|
|
|
|
const enter = dynamic
|
|
|
|
|
? deindent`
|
|
|
|
|
if (${name}) {
|
|
|
|
|
${name}.p(changed, ctx);
|
|
|
|
|
${has_transitions && `@transition_in(${name}, 1);`}
|
|
|
|
|
} else {
|
|
|
|
|
${name} = ${branch.block.name}(ctx);
|
|
|
|
|
${name}.c();
|
|
|
|
|
${has_transitions && `@transition_in(${name}, 1);`}
|
|
|
|
|
${name}.m(${update_mount_node}, ${anchor});
|
|
|
|
|
}
|
|
|
|
|
`
|
|
|
|
|
: deindent`
|
|
|
|
|
if (!${name}) {
|
|
|
|
|
${name} = ${branch.block.name}(ctx);
|
|
|
|
|
${name}.c();
|
|
|
|
|
${has_transitions && `@transition_in(${name}, 1);`}
|
|
|
|
|
${name}.m(${update_mount_node}, ${anchor});
|
|
|
|
|
${has_transitions && `} else {
|
|
|
|
|
@transition_in(${name}, 1);`}
|
|
|
|
|
}
|
|
|
|
|
`;
|
|
|
|
|
if (!branch.dependencies || branch.dependencies.length > 0) {
|
|
|
|
|
const update_mount_node = this.get_update_mount_node(anchor);
|
|
|
|
|
|
|
|
|
|
if (branch.snippet && branch.dependencies.length) {
|
|
|
|
|
block.builders.update.add_block(`if (${branch.dependencies.map(n => `changed.${n}`).join(' || ')}) ${branch.condition} = ${branch.snippet}`);
|
|
|
|
|
}
|
|
|
|
|
const enter = dynamic
|
|
|
|
|
? deindent`
|
|
|
|
|
if (${name}) {
|
|
|
|
|
${name}.p(changed, ctx);
|
|
|
|
|
${has_transitions && `@transition_in(${name}, 1);`}
|
|
|
|
|
} else {
|
|
|
|
|
${name} = ${branch.block.name}(ctx);
|
|
|
|
|
${name}.c();
|
|
|
|
|
${has_transitions && `@transition_in(${name}, 1);`}
|
|
|
|
|
${name}.m(${update_mount_node}, ${anchor});
|
|
|
|
|
}
|
|
|
|
|
`
|
|
|
|
|
: deindent`
|
|
|
|
|
if (!${name}) {
|
|
|
|
|
${name} = ${branch.block.name}(ctx);
|
|
|
|
|
${name}.c();
|
|
|
|
|
${has_transitions && `@transition_in(${name}, 1);`}
|
|
|
|
|
${name}.m(${update_mount_node}, ${anchor});
|
|
|
|
|
} ${has_transitions && `else @transition_in(${name}, 1);`}
|
|
|
|
|
`;
|
|
|
|
|
|
|
|
|
|
if (branch.snippet) {
|
|
|
|
|
block.builders.update.add_block(`if (${branch.dependencies.map(n => `changed.${n}`).join(' || ')}) ${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.builders.update.add_block(deindent`
|
|
|
|
|
if (${branch.condition}) {
|
|
|
|
|
${enter}
|
|
|
|
|
} else if (${name}) {
|
|
|
|
|
@group_outros();
|
|
|
|
|
@transition_out(${name}, 1, 1, () => {
|
|
|
|
|
// 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.builders.update.add_block(deindent`
|
|
|
|
|
if (${branch.condition}) {
|
|
|
|
|
${enter}
|
|
|
|
|
} else if (${name}) {
|
|
|
|
|
@group_outros();
|
|
|
|
|
@transition_out(${name}, 1, 1, () => {
|
|
|
|
|
${name} = null;
|
|
|
|
|
});
|
|
|
|
|
@check_outros();
|
|
|
|
|
}
|
|
|
|
|
`);
|
|
|
|
|
} else {
|
|
|
|
|
block.builders.update.add_block(deindent`
|
|
|
|
|
if (${branch.condition}) {
|
|
|
|
|
${enter}
|
|
|
|
|
} else if (${name}) {
|
|
|
|
|
${name}.d(1);
|
|
|
|
|
${name} = null;
|
|
|
|
|
});
|
|
|
|
|
@check_outros();
|
|
|
|
|
}
|
|
|
|
|
`);
|
|
|
|
|
} else {
|
|
|
|
|
block.builders.update.add_block(deindent`
|
|
|
|
|
if (${branch.condition}) {
|
|
|
|
|
${enter}
|
|
|
|
|
} else if (${name}) {
|
|
|
|
|
${name}.d(1);
|
|
|
|
|
${name} = null;
|
|
|
|
|
}
|
|
|
|
|
`);
|
|
|
|
|
}
|
|
|
|
|
`);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
block.builders.destroy.add_line(`${if_name}${name}.d(${detaching});`);
|
|
|
|
|