( node, get_value, is_controlled = false, svg = false, mathml = false, skip_warning = false )
| 49 | * @returns {void} |
| 50 | */ |
| 51 | export function html( |
| 52 | node, |
| 53 | get_value, |
| 54 | is_controlled = false, |
| 55 | svg = false, |
| 56 | mathml = false, |
| 57 | skip_warning = false |
| 58 | ) { |
| 59 | var anchor = node; |
| 60 | |
| 61 | /** @type {string | TrustedHTML} */ |
| 62 | var value = ''; |
| 63 | |
| 64 | if (is_controlled) { |
| 65 | var parent_node = /** @type {Element} */ (node); |
| 66 | |
| 67 | if (hydrating) { |
| 68 | anchor = set_hydrate_node(get_first_child(parent_node)); |
| 69 | } |
| 70 | } |
| 71 | |
| 72 | template_effect(() => { |
| 73 | var effect = /** @type {Effect} */ (active_effect); |
| 74 | |
| 75 | if (value === (value = get_value() ?? '')) { |
| 76 | if (hydrating) hydrate_next(); |
| 77 | return; |
| 78 | } |
| 79 | |
| 80 | if (is_controlled && !hydrating) { |
| 81 | // When @html is the only child, use innerHTML directly. |
| 82 | // This also handles contenteditable, where the user may delete the anchor comment. |
| 83 | effect.nodes = null; |
| 84 | parent_node.innerHTML = /** @type {string} */ (value); |
| 85 | |
| 86 | if (value !== '') { |
| 87 | assign_nodes( |
| 88 | /** @type {TemplateNode} */ (get_first_child(parent_node)), |
| 89 | /** @type {TemplateNode} */ (parent_node.lastChild) |
| 90 | ); |
| 91 | } |
| 92 | |
| 93 | return; |
| 94 | } |
| 95 | |
| 96 | if (effect.nodes !== null) { |
| 97 | remove_effect_dom(effect.nodes.start, /** @type {TemplateNode} */ (effect.nodes.end)); |
| 98 | effect.nodes = null; |
| 99 | } |
| 100 | |
| 101 | if (value === '') return; |
| 102 | |
| 103 | if (hydrating) { |
| 104 | // We're deliberately not trying to repair mismatches between server and client, |
| 105 | // as it's costly and error-prone (and it's an edge case to have a mismatch anyway) |
| 106 | var hash = /** @type {Comment} */ (hydrate_node).data; |
| 107 | |
| 108 | /** @type {TemplateNode | null} */ |
nothing calls this directly
no test coverage detected