(block, parent_node, parent_nodes)
| 19431 | } |
| 19432 | } |
| 19433 | render_dynamic_element(block, parent_node, parent_nodes) { |
| 19434 | this.child_dynamic_element.render(this.child_dynamic_element_block, null, x`#nodes`); |
| 19435 | const previous_tag = block.get_unique_name("previous_tag"); |
| 19436 | const tag2 = this.node.tag_expr.manipulate(block); |
| 19437 | block.add_variable(previous_tag, tag2); |
| 19438 | block.chunks.init.push(b` |
| 19439 | ${this.renderer.options.dev && b`@validate_dynamic_element(${tag2});`} |
| 19440 | let ${this.var} = ${tag2} && ${this.child_dynamic_element_block.name}(#ctx); |
| 19441 | `); |
| 19442 | block.chunks.create.push(b` |
| 19443 | if (${this.var}) ${this.var}.c(); |
| 19444 | `); |
| 19445 | if (this.renderer.options.hydratable) { |
| 19446 | block.chunks.claim.push(b` |
| 19447 | if (${this.var}) ${this.var}.l(${parent_nodes}); |
| 19448 | `); |
| 19449 | } |
| 19450 | block.chunks.mount.push(b` |
| 19451 | if (${this.var}) ${this.var}.m(${parent_node || "#target"}, ${parent_node ? "null" : "#anchor"}); |
| 19452 | `); |
| 19453 | const anchor = this.get_or_create_anchor(block, parent_node, parent_nodes); |
| 19454 | const has_transitions = !!(this.node.intro || this.node.outro); |
| 19455 | const not_equal = this.renderer.component.component_options.immutable ? x`@not_equal` : x`@safe_not_equal`; |
| 19456 | block.chunks.update.push(b` |
| 19457 | if (${tag2}) { |
| 19458 | if (!${previous_tag}) { |
| 19459 | ${this.var} = ${this.child_dynamic_element_block.name}(#ctx); |
| 19460 | ${this.var}.c(); |
| 19461 | ${has_transitions && b`@transition_in(${this.var})`} |
| 19462 | ${this.var}.m(${this.get_update_mount_node(anchor)}, ${anchor}); |
| 19463 | } else if (${not_equal}(${previous_tag}, ${tag2})) { |
| 19464 | ${this.var}.d(1); |
| 19465 | ${this.renderer.options.dev && b`@validate_dynamic_element(${tag2});`} |
| 19466 | ${this.var} = ${this.child_dynamic_element_block.name}(#ctx); |
| 19467 | ${this.var}.c(); |
| 19468 | ${this.var}.m(${this.get_update_mount_node(anchor)}, ${anchor}); |
| 19469 | } else { |
| 19470 | ${this.var}.p(#ctx, #dirty); |
| 19471 | } |
| 19472 | } else if (${previous_tag}) { |
| 19473 | ${has_transitions ? b` |
| 19474 | @group_outros(); |
| 19475 | @transition_out(${this.var}, 1, 1, () => { |
| 19476 | ${this.var} = null; |
| 19477 | }); |
| 19478 | @check_outros(); |
| 19479 | ` : b` |
| 19480 | ${this.var}.d(1); |
| 19481 | ${this.var} = null; |
| 19482 | `} |
| 19483 | } |
| 19484 | ${previous_tag} = ${tag2}; |
| 19485 | `); |
| 19486 | if (this.child_dynamic_element_block.has_intros) { |
| 19487 | block.chunks.intro.push(b`@transition_in(${this.var});`); |
| 19488 | } |
| 19489 | if (this.child_dynamic_element_block.has_outros) { |
| 19490 | block.chunks.outro.push(b`@transition_out(${this.var});`); |
no test coverage detected