remove unused code

pull/3046/head
Richard Harris 6 years ago
parent e2b885886b
commit 152c1cb1a5

@ -146,14 +146,13 @@ export default class IfBlockWrapper extends Wrapper {
const has_else = !(this.branches[this.branches.length - 1].condition); const has_else = !(this.branches[this.branches.length - 1].condition);
const if_name = has_else ? '' : `if (${name}) `; const if_name = has_else ? '' : `if (${name}) `;
const outroing = block.get_unique_name(`outroing_${this.var}`);
const dynamic = this.branches[0].block.has_update_method; // can use [0] as proxy for all, since they necessarily have the same value const dynamic = this.branches[0].block.has_update_method; // can use [0] as proxy for all, since they necessarily have the same value
const has_intros = this.branches[0].block.has_intro_method; const has_intros = this.branches[0].block.has_intro_method;
const has_outros = this.branches[0].block.has_outro_method; const has_outros = this.branches[0].block.has_outro_method;
const has_transitions = has_intros || has_outros; const has_transitions = has_intros || has_outros;
const vars = { name, anchor, if_name, has_else, has_transitions, outroing }; const vars = { name, anchor, if_name, has_else, has_transitions };
const detaching = (parent_node && parent_node !== 'document.head') ? '' : 'detaching'; const detaching = (parent_node && parent_node !== 'document.head') ? '' : 'detaching';
@ -391,16 +390,11 @@ export default class IfBlockWrapper extends Wrapper {
parent_node: string, parent_node: string,
_parent_nodes: string, _parent_nodes: string,
dynamic, dynamic,
{ name, outroing, anchor, if_name, has_transitions }, { name, anchor, if_name, has_transitions },
detaching detaching
) { ) {
const branch = this.branches[0]; const branch = this.branches[0];
if (branch.block.has_outro_method) {
// TODO this probably belongs in the main render method?
block.add_variable(outroing);
}
block.builders.init.add_block(deindent` block.builders.init.add_block(deindent`
var ${name} = (${branch.condition}) && ${branch.block.name}(ctx); var ${name} = (${branch.condition}) && ${branch.block.name}(ctx);
`); `);
@ -442,10 +436,8 @@ export default class IfBlockWrapper extends Wrapper {
if (branch.block.has_outro_method) { if (branch.block.has_outro_method) {
block.builders.update.add_block(deindent` block.builders.update.add_block(deindent`
if (${branch.condition}) { if (${branch.condition}) {
${outroing} = false;
${enter} ${enter}
} else if (${name} && !${outroing}) { } else if (${name}) {
${outroing} = true;
@group_outros(); @group_outros();
@transition_out(${name}, 1, 1, () => { @transition_out(${name}, 1, 1, () => {
${name} = null; ${name} = null;

@ -53,7 +53,7 @@ function create_if_block(ctx) {
} }
function create_fragment(ctx) { function create_fragment(ctx) {
var outroing_if_block, if_block_anchor, current; var if_block_anchor, current;
var if_block = (ctx.num < 5) && create_if_block(ctx); var if_block = (ctx.num < 5) && create_if_block(ctx);
@ -71,7 +71,6 @@ function create_fragment(ctx) {
p(changed, ctx) { p(changed, ctx) {
if (ctx.num < 5) { if (ctx.num < 5) {
outroing_if_block = false;
if (!if_block) { if (!if_block) {
if_block = create_if_block(ctx); if_block = create_if_block(ctx);
if_block.c(); if_block.c();
@ -80,8 +79,7 @@ function create_fragment(ctx) {
} else { } else {
transition_in(if_block, 1); transition_in(if_block, 1);
} }
} else if (if_block && !outroing_if_block) { } else if (if_block) {
outroing_if_block = true;
group_outros(); group_outros();
transition_out(if_block, 1, 1, () => { transition_out(if_block, 1, 1, () => {
if_block = null; if_block = null;

Loading…
Cancel
Save