From 5d1bc8b2e0bcfe1aa31753f0058c568e14dc1d2a Mon Sep 17 00:00:00 2001 From: Yuichiro Yamashita Date: Sun, 31 Oct 2021 13:06:50 +0900 Subject: [PATCH] refactor render_dom --- .../render_dom/wrappers/DynamicElement.ts | 31 ++++++------------- 1 file changed, 9 insertions(+), 22 deletions(-) diff --git a/src/compiler/compile/render_dom/wrappers/DynamicElement.ts b/src/compiler/compile/render_dom/wrappers/DynamicElement.ts index e462f6fc0f..feb23ac5b0 100644 --- a/src/compiler/compile/render_dom/wrappers/DynamicElement.ts +++ b/src/compiler/compile/render_dom/wrappers/DynamicElement.ts @@ -42,11 +42,7 @@ export default class DynamicElementWrapper extends Wrapper { ); } - render( - block: Block, - parent_node: Identifier, - parent_nodes: Identifier - ) { + render(block: Block, parent_node: Identifier, parent_nodes: Identifier) { this.elementWrapper.render( this.dynamic_element_block, null, @@ -56,7 +52,6 @@ export default class DynamicElementWrapper extends Wrapper { const has_transitions = !!( this.dynamic_element_block.has_intro_method || this.dynamic_element_block.has_outro_method ); - const dynamic = this.dynamic_element_block.has_update_method; const previous_tag = block.get_unique_name('previous_tag'); const snippet = this.node.dynamic_tag_expr.manipulate(block); @@ -101,22 +96,14 @@ export default class DynamicElementWrapper extends Wrapper { ${this.var}.m(${this.get_update_mount_node(anchor)}, ${anchor}); `; - if (dynamic) { - block.chunks.update.push(b` - if (${condition}) { - ${body} - } else { - ${this.var}.p(#ctx, #dirty); - } - `); - } else { - block.chunks.update.push(b` - if (${condition}) { - ${body} - } - `); - } - } else if (dynamic) { + block.chunks.update.push(b` + if (${condition}) { + ${body} + } else { + ${this.var}.p(#ctx, #dirty); + } + `); + } else { block.chunks.update.push(b` ${this.var}.p(#ctx, #dirty); if (${condition}) {