From 152c1cb1a579a7dce71653b9bfc218eae0f57260 Mon Sep 17 00:00:00 2001 From: Richard Harris Date: Tue, 18 Jun 2019 22:36:24 -0400 Subject: [PATCH] remove unused code --- .../compile/render-dom/wrappers/IfBlock.ts | 14 +++----------- .../samples/transition-repeated-outro/expected.js | 6 ++---- 2 files changed, 5 insertions(+), 15 deletions(-) diff --git a/src/compiler/compile/render-dom/wrappers/IfBlock.ts b/src/compiler/compile/render-dom/wrappers/IfBlock.ts index ad51c319a2..8c18a6bfb0 100644 --- a/src/compiler/compile/render-dom/wrappers/IfBlock.ts +++ b/src/compiler/compile/render-dom/wrappers/IfBlock.ts @@ -146,14 +146,13 @@ export default class IfBlockWrapper extends Wrapper { const has_else = !(this.branches[this.branches.length - 1].condition); 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 has_intros = this.branches[0].block.has_intro_method; const has_outros = this.branches[0].block.has_outro_method; 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'; @@ -391,16 +390,11 @@ export default class IfBlockWrapper extends Wrapper { parent_node: string, _parent_nodes: string, dynamic, - { name, outroing, anchor, if_name, has_transitions }, + { name, anchor, if_name, has_transitions }, detaching ) { 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` var ${name} = (${branch.condition}) && ${branch.block.name}(ctx); `); @@ -442,10 +436,8 @@ export default class IfBlockWrapper extends Wrapper { if (branch.block.has_outro_method) { block.builders.update.add_block(deindent` if (${branch.condition}) { - ${outroing} = false; ${enter} - } else if (${name} && !${outroing}) { - ${outroing} = true; + } else if (${name}) { @group_outros(); @transition_out(${name}, 1, 1, () => { ${name} = null; diff --git a/test/js/samples/transition-repeated-outro/expected.js b/test/js/samples/transition-repeated-outro/expected.js index bf58404941..8543d0029b 100644 --- a/test/js/samples/transition-repeated-outro/expected.js +++ b/test/js/samples/transition-repeated-outro/expected.js @@ -53,7 +53,7 @@ function create_if_block(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); @@ -71,7 +71,6 @@ function create_fragment(ctx) { p(changed, ctx) { if (ctx.num < 5) { - outroing_if_block = false; if (!if_block) { if_block = create_if_block(ctx); if_block.c(); @@ -80,8 +79,7 @@ function create_fragment(ctx) { } else { transition_in(if_block, 1); } - } else if (if_block && !outroing_if_block) { - outroing_if_block = true; + } else if (if_block) { group_outros(); transition_out(if_block, 1, 1, () => { if_block = null;