1//#region Assets/js-libs/bem/bem.mjs 2var Bem = function(baseEl, baseBlockName) { 3 const that = this; 4 function toNodeList(elm, context) { 5 try { 6 var list, df; 7 context = context || elm.parentNode; 8 if (!context && elm.ownerDocument) { 9 if (elm === elm.ownerDocument.documentElement || elm.ownerDocument.constructor.name === "DocumentFragment") context = elm.ownerDocument; 10 } 11 if (!context) { 12 df = document.createDocumentFragment(); 13 df.appendChild(elm); 14 list = df.childNodes; 15 return list; 16 } 17 elm.setAttribute("wrapNodeList", ""); 18 list = context.querySelectorAll("[wrapNodeList]"); 19 elm.removeAttribute("wrapNodeList"); 20 return list; 21 } catch (_ex) { 22 console.warn("====", { "elm": elm }); 23 return elm; 24 } 25 } 26 this.baseEl = new toNodeList(baseEl); 27 this.currentEl = this.baseEl; 28 this.currentBlockName = baseBlockName; 29 this.currentElementName = null; 30 this.currentModifierName = null; 31 this.currentModifierValue = null; 32 this.selectBlock = () => { 33 this.currentElementName = null; 34 this.currentModifierName = null; 35 this.currentModifierValue = null; 36 this.currentEl = this.baseEl;
37 return that; 38 }; 39 this.getSelectedElements = () => { 40 this.currentModifierName = null; 41 this.currentModifierValue = null; 42 this.currentEl = this.baseEl[0].querySelectorAll(`.${this.currentBlockName}__${this.currentElementName}`); 43 return this.currentEl; 44 }; 45 this.selectElements = (elementName, callback) => { 46 this.selectBlock(); 47 this.currentElementName = elementName; 48 this.currentEl = find(this.currentEl, `.${this.currentBlockName}__${elementName}`); 49 if (typeof callback === "function") this.currentEl.forEach((el) => { 50 callback(el, that); 51 }); 52 return that; 53 }; 54 this.selectElementsWithModifier = (elementName, modifier, value, callback) => { 55 value = value.toString(); 56 this.selectBlock(); 57 this.currentElementName = elementName; 58 this.currentModifierName = modifier; 59 this.currentModifierValue = value; 60 if (typeof modifier !== "undefined" && modifier !== null) { 61 if (typeof value === "undefined" || value === null) value = "true"; 62 this.currentEl = find(this.currentEl, `.${this.currentBlockName}__${elementName}_${modifier}_${value}`); 63 } else this.currentEl = find(this.currentEl, `.${this.currentBlockName}__${elementName}`); 64 if (typeof callback === "function") this.currentEl.forEach((el) => { 65 callback(el, that); 66 }); 67 return that; 68 }; 69 this.each = (callback) => { 70 this.currentEl.forEach((el, i) => { 71 callback(el, that, i); 72 }); 73 }; 74 this.removeModifier = (modifier) => { 75 if (that.currentElementName !== null) that.currentEl.forEach((el) => { 76 el.classList.forEach((className) => { 77 if (className.startsWith(`${that.currentBlockName}__${that.currentElementName}_${modifier}_`)) el.classList.remove(className); 78 }); 79 }); 80 else that.currentEl.forEach((el) => { 81 el.classList.forEach((className) => { 82 if (className.startsWith(`${that.currentBlockName}_${modifier}_`)) el.classList.remove(className); 83 }); 84 }); 85 }; 86 this.setModifier = (modifier, value) => { 87 if (typeof value === "undefined") value = "true"; 88 value = value.toString(); 89 that.currentModifierName = modifier; 90 that.currentModifierValue = value; 91 that.removeModifier(modifier); 92 if (that.currentElementName !== null) that.currentEl.forEach((el) => { 93 el.classList.add(`${that.currentBlockName}__${that.currentElementName}_${modifier}_${value}`); 94 }); 95 else that.currentEl.forEach((el) => { 96 el.classList.add(`${that.currentBlockName}_${modifier}_${value}`); 97 }); 98 return that; 99 }; 100 const find = (haystackNodeList, needleSelector) => { 101 let result = []; 102 Array.prototype.forEach.call(haystackNodeList, (node) => { 103 const foundNeedleNodes = node.querySelectorAll(needleSelector); 104 const foundNeedles = Array.from(foundNeedleNodes); 105 result.push.apply(result, foundNeedles); 106 }); 107 return result; 108 }; 109}; 110//#endregion 111export { Bem as t }; 112 113//# sourceMappingURL=bem-DRONJtun.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.