1/** 2 * Minified by jsDelivr using Terser v3.14.1. 3 * Original file: /npm/[email protected]/dist/morphdom.js 4 * 5 * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files 6 */ 7 8function translatedCartDiscount(discount) { 9 var percent = Math.round(Number(discount) * 10000) / 100; 10 return translateText('Extra {{percent}}% off applied') 11 .split('{{percent}}').join(String(percent)); 12} 13 14function translatedCartDiscountHtml(discount) { 15 // This complete phrase is already translated. The legacy LR leaf walker 16 // must not replace short English substrings inside it a second time. 17 var span = document.createElement('span'); 18 span.setAttribute('data-cart-translated', ''); 19 span.textContent = translatedCartDiscount(discount); 20 return span.outerHTML; 21} 22 23function renderHTML(htmlString = '') { 24 var template = document.createElement('template'); 25 var html = ''; 26 console.log({ htmlString }); 27 if (htmlString.trim) { 28 html = htmlString.trim(); // Never return a text node of whitespace as the result 29 } 30 template.innerHTML = html; 31 32 if ( 33 typeof commonTranslationDictionary != 'undefined' && 34 pageLanguage != 'en' 35 ) { 36 console.log('replacing text in leaf nodes with translations'); 37 // Replace text in leaf text nodes with translations 38 replaceTextInLeafNodes(template.content.firstChild); 39 } else { 40 console.log('no translations to replace'); 41 } 42 43 return template.content.firstChild; 44} 45 46/** 47 * Recursively replace text in leaf text nodes with translations 48 * @param {Node} node - The node to process 49 */ 50function replaceTextInLeafNodes(node) { 51 console.log('replaceTextInLeafNodes', { node }); 52 if (!node || !commonTranslationDictionary) return; 53 54 // If this is a text node, replace its content 55 if (node.nodeType === Node.TEXT_NODE) { 56 let text = node.textContent; 57 let originalText = text; 58 59 // Use the global translateText function 60 text = translateText(text); 61 62 if (text !== originalText) { 63 node.textContent = text; 64 } 65 return; 66 } 67 68 // Otherwise, recurse into children 69 if (node.nodeType === Node.ELEMENT_NODE) { 70 if (node.hasAttribute('data-cart-translated')) return; 71 node.childNodes.forEach((child) => replaceTextInLeafNodes(child)); 72 } 73} 74 75function removeAllChildNodes(parent) { 76 while (parent.firstChild) { 77 parent.removeChild(parent.firstChild); 78 } 79} 80 81('use strict'); 82var range, 83 DOCUMENT_FRAGMENT_NODE = 11; 84function morphAttrs(e, t) { 85 var n, 86 r, 87 o, 88 a, 89 i = t.attributes; 90 if ( 91 t.nodeType !== DOCUMENT_FRAGMENT_NODE && 92 e.nodeType !== DOCUMENT_FRAGMENT_NODE 93 ) { 94 for (var d = i.length - 1; d >= 0; d--) 95 (r = (n = i[d]).name), 96 (o = n.namespaceURI), 97 (a = n.value), 98 o 99 ? ((r = n.localName || r), 100 e.getAttributeNS(o, r) !== a && 101 ('xmlns' === n.prefix && (r = n.name), e.setAttributeNS(o, r, a))) 102 : e.getAttribute(r) !== a && e.setAttribute(r, a); 103 for (var l = e.attributes, c = l.length - 1; c >= 0; c--) 104 (r = (n = l[c]).name), 105 (o = n.namespaceURI) 106 ? ((r = n.localName || r), 107 t.hasAttributeNS(o, r) || e.removeAttributeNS(o, r)) 108 : t.hasAttribute(r) || e.removeAttribute(r); 109 } 110} 111var NS_XHTML = 'https://www.w3.org/1999/xhtml', 112 doc = 'undefined' == typeof document ? void 0 : document, 113 HAS_TEMPLATE_SUPPORT = !!doc && 'content' in doc.createElement('template'), 114 HAS_RANGE_SUPPORT = 115 !!doc && doc.createRange && 'createContextualFragment' in doc.createRange(); 116function createFragmentFromTemplate(e) { 117 var t = doc.createElement('template'); 118 return (t.innerHTML = e), t.content.childNodes[0]; 119} 120function createFragmentFromRange(e) { 121 return ( 122 range || (range = doc.createRange()).selectNode(doc.body), 123 range.createContextualFragment(e).childNodes[0] 124 ); 125} 126function createFragmentFromWrap(e) { 127 var t = doc.createElement('body'); 128 return (t.innerHTML = e), t.childNodes[0]; 129} 130function toElement(e) { 131 return ( 132 (e = e.trim()), 133 HAS_TEMPLATE_SUPPORT 134 ? createFragmentFromTemplate(e) 135 : HAS_RANGE_SUPPORT 136 ? createFragmentFromRange(e) 137 : createFragmentFromWrap(e) 138 ); 139} 140function compareNodeNames(e, t) { 141 var n, 142 r,
143 o = e.nodeName, 144 a = t.nodeName; 145 return ( 146 o === a || 147 ((n = o.charCodeAt(0)), 148 (r = a.charCodeAt(0)), 149 n <= 90 && r >= 97 150 ? o === a.toUpperCase() 151 : r <= 90 && n >= 97 && a === o.toUpperCase()) 152 ); 153} 154function createElementNS(e, t) { 155 return t && t !== NS_XHTML ? doc.createElementNS(t, e) : doc.createElement(e); 156} 157function moveChildren(e, t) { 158 for (var n = e.firstChild; n; ) { 159 var r = n.nextSibling; 160 t.appendChild(n), (n = r); 161 } 162 return t; 163} 164function syncBooleanAttrProp(e, t, n) { 165 e[n] !== t[n] && 166 ((e[n] = t[n]), e[n] ? e.setAttribute(n, '') : e.removeAttribute(n)); 167} 168var specialElHandlers = { 169 OPTION: function (e, t) { 170 var n = e.parentNode; 171 if (n) { 172 var r = n.nodeName.toUpperCase(); 173 'OPTGROUP' === r && 174 (r = (n = n.parentNode) && n.nodeName.toUpperCase()), 175 'SELECT' !== r || 176 n.hasAttribute('multiple') || 177 (e.hasAttribute('selected') && 178 !t.selected && 179 (e.setAttribute('selected', 'selected'), 180 e.removeAttribute('selected')), 181 (n.selectedIndex = -1)); 182 } 183 syncBooleanAttrProp(e, t, 'selected'); 184 }, 185 INPUT: function (e, t) { 186 syncBooleanAttrProp(e, t, 'checked'), 187 syncBooleanAttrProp(e, t, 'disabled'), 188 e.value !== t.value && (e.value = t.value), 189 t.hasAttribute('value') || e.removeAttribute('value'); 190 }, 191 TEXTAREA: function (e, t) { 192 var n = t.value; 193 e.value !== n && (e.value = n); 194 var r = e.firstChild; 195 if (r) { 196 var o = r.nodeValue; 197 if (o == n || (!n && o == e.placeholder)) return; 198 r.nodeValue = n; 199 } 200 }, 201 SELECT: function (e, t) { 202 if (!t.hasAttribute('multiple')) { 203 for (var n, r, o = -1, a = 0, i = e.firstChild; i; ) 204 if ('OPTGROUP' === (r = i.nodeName && i.nodeName.toUpperCase())) 205 i = (n = i).firstChild; 206 else { 207 if ('OPTION' === r) { 208 if (i.hasAttribute('selected')) { 209 o = a; 210 break; 211 } 212 a++; 213 } 214 !(i = i.nextSibling) && n && ((i = n.nextSibling), (n = null)); 215 } 216 e.selectedIndex = o; 217 } 218 }, 219 }, 220 ELEMENT_NODE = 1, 221 DOCUMENT_FRAGMENT_NODE$1 = 11, 222 TEXT_NODE = 3, 223 COMMENT_NODE = 8; 224function noop() {} 225function defaultGetNodeKey(e) { 226 if (e) return (e.getAttribute && e.getAttribute('id')) || e.id; 227} 228function morphdomFactory(e) { 229 return function (t, n, r) { 230 if ((r || (r = {}), 'string' == typeof n)) 231 if ( 232 '#document' === t.nodeName || 233 'HTML' === t.nodeName || 234 'BODY' === t.nodeName 235 ) { 236 var o = n; 237 (n = doc.createElement('html')).innerHTML = o; 238 } else n = toElement(n); 239 var a = r.getNodeKey || defaultGetNodeKey, 240 i = r.onBeforeNodeAdded || noop, 241 d = r.onNodeAdded || noop, 242 l = r.onBeforeElUpdated || noop, 243 c = r.onElUpdated || noop, 244 u = r.onBeforeNodeDiscarded || noop, 245 N = r.onNodeDiscarded || noop, 246 m = r.onBeforeElChildrenUpdated || noop, 247 f = !0 === r.childrenOnly, 248 E = Object.create(null), 249 s = []; 250 function p(e) { 251 s.push(e); 252 } 253 function T(e, t, n) { 254 !1 !== u(e) && 255 (t && t.removeChild(e), 256 N(e), 257 (function e(t, n) { 258 if (t.nodeType === ELEMENT_NODE) 259 for (var r = t.firstChild; r; ) { 260 var o = void 0; 261 n && (o = a(r)) ? p(o) : (N(r), r.firstChild && e(r, n)), 262 (r = r.nextSibling); 263 } 264 })(e, n)); 265 } 266 function v(e) { 267 d(e); 268 for (var t = e.firstChild; t; ) { 269 var n = t.nextSibling, 270 r = a(t); 271 if (r) { 272 var o = E[r]; 273 o && compareNodeNames(t, o) 274 ? (t.parentNode.replaceChild(o, t), A(o, t)) 275 : v(t); 276 } else v(t); 277 t = n; 278 } 279 } 280 function A(t, n, r) { 281 var o = a(n); 282 if ((o && delete E[o], !r)) { 283 if (!1 === l(t, n)) return; 284 if ((e(t, n), c(t), !1 === m(t, n))) return; 285 } 286 'TEXTAREA' !== t.nodeName 287 ? (function (e, t) { 288 var n, 289 r, 290 o, 291 d, 292 l, 293 c = t.firstChild, 294 u = e.firstChild; 295 e: for (; c; ) { 296 for (d = c.nextSibling, n = a(c); u; ) { 297 if (((o = u.nextSibling), c.isSameNode && c.isSameNode(u))) { 298 (c = d), (u = o); 299 continue e; 300 } 301 r = a(u); 302 var N = u.nodeType, 303 m = void 0; 304 if ( 305 (N === c.nodeType && 306 (N === ELEMENT_NODE 307 ? (n 308 ? n !== r && 309 ((l = E[n]) 310 ? o === l 311 ? (m = !1) 312 : (e.insertBefore(l, u), 313 r ? p(r) : T(u, e, !0), 314 (u = l)) 315 : (m = !1)) 316 : r && (m = !1), 317 (m = !1 !== m && compareNodeNames(u, c)) && A(u, c)) 318 : (N !== TEXT_NODE && N != COMMENT_NODE) || 319 ((m = !0), 320 u.nodeValue !== c.nodeValue && 321 (u.nodeValue = c.nodeValue))), 322 m) 323 ) { 324 (c = d), (u = o); 325 continue e; 326 } 327 r ? p(r) : T(u, e, !0), (u = o); 328 } 329 if (n && (l = E[n]) && compareNodeNames(l, c)) 330 e.appendChild(l), A(l, c); 331 else { 332 var f = i(c); 333 !1 !== f && 334 (f && (c = f), 335 c.actualize && (c = c.actualize(e.ownerDocument || doc)), 336 e.appendChild(c), 337 v(c)); 338 } 339 (c = d), (u = o); 340 } 341 !(function (e, t, n) { 342 for (; t; ) { 343 var r = t.nextSibling; 344 (n = a(t)) ? p(n) : T(t, e, !0), (t = r); 345 } 346 })(e, u, r); 347 var s = specialElHandlers[e.nodeName]; 348 s && s(e, t); 349 })(t, n) 350 : specialElHandlers.TEXTAREA(t, n); 351 } 352 !(function e(t) { 353 if ( 354 t.nodeType === ELEMENT_NODE || 355 t.nodeType === DOCUMENT_FRAGMENT_NODE$1 356 ) 357 for (var n = t.firstChild; n; ) { 358 var r = a(n); 359 r && (E[r] = n), e(n), (n = n.nextSibling); 360 } 361 })(t); 362 var h = t, 363 O = h.nodeType, 364 C = n.nodeType; 365 if (!f) 366 if (O === ELEMENT_NODE) 367 C === ELEMENT_NODE 368 ? compareNodeNames(t, n) || 369 (N(t), 370 (h = moveChildren(t, createElementNS(n.nodeName, n.namespaceURI)))) 371 : (h = n); 372 else if (O === TEXT_NODE || O === COMMENT_NODE) { 373 if (C === O) 374 return h.nodeValue !== n.nodeValue && (h.nodeValue = n.nodeValue), h; 375 h = n; 376 } 377 if (h === n) N(t); 378 else { 379 if (n.isSameNode && n.isSameNode(h)) return; 380 if ((A(h, n, f), s)) 381 for (var b = 0, g = s.length; b < g; b++) { 382 var S = E[s[b]]; 383 S && T(S, S.parentNode, !1); 384 } 385 } 386 return ( 387 !f && 388 h !== t && 389 t.parentNode && 390 (h.actualize && (h = h.actualize(t.ownerDocument || doc)), 391 t.parentNode.replaceChild(h, t)), 392 h 393 ); 394 }; 395} 396var morphdom = morphdomFactory(morphAttrs); 397// module.exports = morphdom;
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.