(node, is_text = false)
| 139 | * @returns {TemplateNode | null} |
| 140 | */ |
| 141 | export function first_child(node, is_text = false) { |
| 142 | if (!hydrating) { |
| 143 | var first = get_first_child(node); |
| 144 | |
| 145 | // TODO prevent user comments with the empty string when preserveComments is true |
| 146 | if (first instanceof Comment && first.data === '') return get_next_sibling(first); |
| 147 | |
| 148 | return first; |
| 149 | } |
| 150 | |
| 151 | if (is_text) { |
| 152 | // if an {expression} is empty during SSR, there might be no |
| 153 | // text node to hydrate — we must therefore create one |
| 154 | if (hydrate_node?.nodeType !== TEXT_NODE) { |
| 155 | var text = create_text(); |
| 156 | |
| 157 | hydrate_node?.before(text); |
| 158 | set_hydrate_node(text); |
| 159 | return text; |
| 160 | } |
| 161 | |
| 162 | merge_text_nodes(/** @type {Text} */ (hydrate_node)); |
| 163 | } |
| 164 | |
| 165 | return hydrate_node; |
| 166 | } |
| 167 | |
| 168 | /** |
| 169 | * Don't mark this as side-effect-free, hydration needs to walk all nodes |
nothing calls this directly
no test coverage detected