From f51d0f5b331d2e251c4b54a41e324e7777e73537 Mon Sep 17 00:00:00 2001 From: Yuichiro Yamashita Date: Sat, 6 Nov 2021 12:22:50 +0900 Subject: [PATCH] refactor render_dom --- .../render_dom/wrappers/Element/index.ts | 38 ++++--------------- 1 file changed, 8 insertions(+), 30 deletions(-) diff --git a/src/compiler/compile/render_dom/wrappers/Element/index.ts b/src/compiler/compile/render_dom/wrappers/Element/index.ts index 3396ad421e..5f0e470589 100644 --- a/src/compiler/compile/render_dom/wrappers/Element/index.ts +++ b/src/compiler/compile/render_dom/wrappers/Element/index.ts @@ -371,50 +371,28 @@ export default class ElementWrapper extends Wrapper { const render_statement = this.get_render_statement(block); const mounted: Identifier = { type: 'Identifier', name: '#mounted' }; - const statement = (b` - @detach(${node}); - ${node} = ${render_statement}; - ${block.chunks.hydrate} - ${block.event_listeners.length && b`${mounted} = false`}; - ${staticChildren} - `); - - const has_transitions = !!(block.has_intro_method || block.has_outro_method); const anchor = this.get_or_create_anchor(block, parent_node, parent_nodes); const not_equal = this.renderer.component.component_options.immutable ? x`@not_equal` : x`@safe_not_equal`; const if_statement = x`${not_equal}(${previous_tag}, ${previous_tag} = ${snippet})`; - if (has_transitions) { - const body = b` - ${statement} - this.m(${this.get_update_mount_node(anchor)}, ${anchor}); - ${transition_names.outro_name && b`${transition_names.outro_name} = null;`} - `; - - block.chunks.update.push(b` - if (${if_statement}) { - ${body} - } - `); - } else { - block.chunks.update.push(b` + block.chunks.update.push(b` if (${if_statement}) { - ${statement} + @detach(${node}); + ${node} = ${render_statement}; + ${block.chunks.hydrate} + ${block.event_listeners.length && b`${mounted} = false`}; + ${staticChildren} this.m(${this.get_update_mount_node(anchor)}, ${anchor}); + ${transition_names.outro_name && b`${transition_names.outro_name} = null;`} + ${this.renderer.options.dev && b`@validate_dynamic_element(${snippet});`} } `); - } if (this.renderer.options.dev) { block.chunks.create.push(b`@validate_dynamic_element(${snippet});`); if (renderer.options.hydratable) { block.chunks.claim.push(b`@validate_dynamic_element(${snippet});`); } - block.chunks.update.push(b` - if (${if_statement}) { - @validate_dynamic_element(${snippet}); - } - `); } } }