merge duplicated if statement

pull/7468/head
Yuichiro Yamashita 4 years ago
parent 6b229da58b
commit 7b1af96c17

@ -405,8 +405,20 @@ export default class InlineComponentWrapper extends Wrapper {
const snippet = this.node.expression.manipulate(block); const snippet = this.node.expression.manipulate(block);
let css_custom_properties_wrapper_anchor = null;
if (has_css_custom_properties) { if (has_css_custom_properties) {
this.set_css_custom_properties(block, css_custom_properties_wrapper); this.set_css_custom_properties(block, css_custom_properties_wrapper);
if ((this.next ? !this.next.is_dom_node() : !parent_node || !this.parent.is_dom_node())) {
css_custom_properties_wrapper_anchor = block.get_unique_name(`${this.var.name}_anchor`);
block.add_element(
css_custom_properties_wrapper_anchor,
x`@empty()`,
parent_nodes && x`@empty()`,
parent_node
);
} else {
css_custom_properties_wrapper_anchor = (this.next && this.next.var) || parent_node;
}
} }
this.create_claim_chunk(block, parent_nodes, name, css_custom_properties_wrapper); this.create_claim_chunk(block, parent_nodes, name, css_custom_properties_wrapper);
@ -435,31 +447,16 @@ export default class InlineComponentWrapper extends Wrapper {
b`if (${name}) @create_component(${name}.$$.fragment);` b`if (${name}) @create_component(${name}.$$.fragment);`
); );
const tmp_anchor = this.get_or_create_anchor(block, parent_node, parent_nodes);
const anchor = css_custom_properties_wrapper ? 'null' : tmp_anchor;
const update_mount_node = has_css_custom_properties ? css_custom_properties_wrapper : this.get_update_mount_node(tmp_anchor);
let css_custom_properties_wrapper_anchor = null;
if (has_css_custom_properties) {
if ((this.next ? !this.next.is_dom_node() : !parent_node || !this.parent.is_dom_node())) {
css_custom_properties_wrapper_anchor = block.get_unique_name(`${this.var.name}_anchor`);
block.add_element(
css_custom_properties_wrapper_anchor,
x`@empty()`,
parent_nodes && x`@empty()`,
parent_node
);
} else {
css_custom_properties_wrapper_anchor = (this.next && this.next.var) || parent_node;
}
}
if (updates.length) { if (updates.length) {
block.chunks.update.push(b` block.chunks.update.push(b`
${updates} ${updates}
`); `);
} }
const tmp_anchor = this.get_or_create_anchor(block, parent_node, parent_nodes);
const anchor = css_custom_properties_wrapper ? 'null' : tmp_anchor;
const update_mount_node = has_css_custom_properties ? css_custom_properties_wrapper : this.get_update_mount_node(tmp_anchor);
block.chunks.update.push(b` block.chunks.update.push(b`
if (${switch_value} !== (${switch_value} = ${snippet})) { if (${switch_value} !== (${switch_value} = ${snippet})) {
if (${name}) { if (${name}) {

Loading…
Cancel
Save