1import { t as template_effect, b as active_effect, r as remove_effect_dom, c as create_fragment_from_html, d as assign_nodes, g as get_first_child, h as hydrating, e as hydrate_next, i as hydrate_node, C as COMMENT_NODE, j as get_next_sibling, k as hydration_mismatch, H as HYDRATION_ERROR, D as DEV, s as set_hydrate_node, l as hash, m as dev_current_component_function, F as FILENAME, n as hydration_html_changed, o as sanitize_location } from './index-CDZuCcOm.js'; 2 3/** @import { Effect, TemplateNode } from '#client' */ 4 5/** 6 * @param {Element} element 7 * @param {string | null} server_hash 8 * @param {string} value 9 */ 10function check_hash(element, server_hash, value) { 11 if (!server_hash || server_hash === hash(String(value ?? ''))) return; 12 13 let location; 14 15 // @ts-expect-error 16 const loc = element.__svelte_meta?.loc; 17 if (loc) { 18 location = `near ${loc.file}:${loc.line}:${loc.column}`; 19 } else if (dev_current_component_function?.[FILENAME]) { 20 location = `in ${dev_current_component_function[FILENAME]}`; 21 } 22 23 hydration_html_changed(sanitize_location(location)); 24} 25 26/** 27 * @param {Element | Text | Comment} node 28 * @param {() => string} get_value 29 * @param {boolean} [svg] 30 * @param {boolean} [mathml] 31 * @param {boolean} [skip_warning] 32 * @returns {void} 33 */ 34function html(node, get_value, svg = false, mathml = false, skip_warning = false) { 35 var anchor = node; 36 37 var value = ''; 38 39 template_effect(() => { 40 var effect = /** @type {Effect} */ (active_effect); 41 42 if (value === (value = get_value() ?? '')) { 43 if (hydrating) hydrate_next(); 44 return; 45 } 46 47 if (effect.nodes !== null) { 48 remove_effect_dom(effect.nodes.start, /** @type {TemplateNode} */ (effect.nodes.end)); 49 effect.nodes = null; 50 } 51 52 if (value === '') return; 53 54 if (hydrating) { 55 // We're deliberately not trying to repair mismatches between server and client, 56 // as it's costly and error-prone (and it's an edge case to have a mismatch anyway) 57 var hash = /** @type {Comment} */ (hydrate_node).data; 58 59 /** @type {TemplateNode | null} */ 60 var next = hydrate_next(); 61 var last = next; 62 63 while ( 64 next !== null && 65 (next.nodeType !== COMMENT_NODE || /** @type {Comment} */ (next).data !== '') 66 ) { 67 last = next; 68 next = get_next_sibling(next); 69 } 70 71 if (next === null) { 72 hydration_mismatch(); 73 throw HYDRATION_ERROR; 74 } 75 76 if (DEV && !skip_warning) { 77 check_hash(/** @type {Element} */ (next.parentNode), hash, value); 78 } 79 80 assign_nodes(hydrate_node, last); 81 anchor = set_hydrate_node(next); 82 return; 83 } 84 85 var html = value + ''; 86 if (svg) html = `<svg>${html}</svg>`; 87 else if (mathml) html = `<math>${html}</math>`; 88 89 // Don't use create_fragment_with_script_from_html here because that would mean script tags are executed. 90 // @html is basically `.innerHTML = ...` and that doesn't execute scripts either due to security reasons. 91 /** @type {DocumentFragment | Element} */ 92 var node = create_fragment_from_html(html); 93 94 if (svg || mathml) { 95 node = /** @type {Element} */ (get_first_child(node)); 96 } 97 98 assign_nodes( 99 /** @type {TemplateNode} */ (get_first_child(node)), 100 /** @type {TemplateNode} */ (node.lastChild) 101 ); 102 103 if (svg || mathml) { 104 while (get_first_child(node)) { 105 anchor.before(/** @type {TemplateNode} */ (get_first_child(node))); 106 } 107 } else { 108 anchor.before(node); 109 } 110 }); 111} 112 113export { html as h }; 114//# sourceMappingURL=html-h_YSgefI.js.map
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.