(node, is_text)
| 108 | * @returns {TemplateNode | null} |
| 109 | */ |
| 110 | export function child(node, is_text) { |
| 111 | if (!hydrating) { |
| 112 | return get_first_child(node); |
| 113 | } |
| 114 | |
| 115 | var child = get_first_child(hydrate_node); |
| 116 | |
| 117 | // Child can be null if we have an element with a single child, like `<p>{text}</p>`, where `text` is empty |
| 118 | if (child === null) { |
| 119 | child = hydrate_node.appendChild(create_text()); |
| 120 | } else if (is_text && child.nodeType !== TEXT_NODE) { |
| 121 | var text = create_text(); |
| 122 | child?.before(text); |
| 123 | set_hydrate_node(text); |
| 124 | return text; |
| 125 | } |
| 126 | |
| 127 | if (is_text) { |
| 128 | merge_text_nodes(/** @type {Text} */ (child)); |
| 129 | } |
| 130 | |
| 131 | set_hydrate_node(child); |
| 132 | return child; |
| 133 | } |
| 134 | |
| 135 | /** |
| 136 | * Don't mark this as side-effect-free, hydration needs to walk all nodes |
nothing calls this directly
no test coverage detected