PageSourceSearch

https://www.ohpolly.com/cdn/shop/t/1735/assets/bao-custom-element.js?v=166085879487581956251782836742

js ohpolly.com collected 2026-10-03 20:36:19 UTC 5,650 bytes, 14 lines download raw bytes

1window.BAO.CustomElement=function({SuperClass=HTMLElement}={}){class CustomElement extends SuperClass{static get requiredElements(){return[]}static get requiredExternalElements(){return[]}static get requiredAttributes(){return[]}static get styles(){return""}constructor(){if(super(),this._hasBeenInitialised=!1,this.sections=[],this.listeners=new window.BAO.Listeners,this.checkValidity(),this.constructor.styles){const shadow=this.attachShadow({mode:"open"}),style=document.createElement("style"),slot=document.createElement("slot");shadow.appendChild(style),shadow.appendChild(slot)}}connectedCallback(){this._hasBeenInitialised||(this._hasBeenInitialised=!0,this.setupListeners(),this.applyStyles())}disconnectedCallback(){this.listeners.removeAll()}checkValidity(){if(this.constructor.requiredElements.length===0&&this.constructor.requiredExternalElements.length===0&&this.constructor.requiredAttributes.length===0)return;const requiredElementsNotPresent=this.constructor.requiredElements.filter(name=>!(name in this.els)),requiredExternalElementsNotPresent=this.constructor.requiredExternalElements.filter(name=>!(name in this.externalEls)),requiredAttributesNotPresent=this.constructor.requiredAttributes.filter(name=>!this.getAttributeNames().includes(name));if(requiredElementsNotPresent.length===0&&requiredExternalElementsNotPresent.length===0&&requiredAttributesNotPresent.length===0)return;requiredAttributesNotPresent.forEach(requiredAttributeName=>{this.throwError(`needs a '${requiredAttributeName}' attribute`)});const requiredElementsMessages=requiredElementsNotPresent.map(name=>`- ${this._elIdentifier}="${name}"`).join(`
2`),requiredExternalElementsMessages=requiredExternalElementsNotPresent.map(name=>`- ${this._externalElIdentifier}="${name}"`).join(`
3`),requiredAttributesMessages=requiredAttributesNotPresent.map(name=>`- ${name}`).join(`
4`);let message="Has errors, please read below";requiredElementsNotPresent.length>0&&(message+=`
5
6Missing required elements:
7  ${requiredElementsMessages}`),requiredExternalElementsNotPresent.length>0&&(message+=`
8
9Missing external required elements:
10  ${requiredExternalElementsMessages}`),requiredAttributesNotPresent.length>0&&(message+=`
11
12Missing required attributes:
13  ${requiredAttributesMessages}`),this.throwError(message)}throwError(message){throw`<${this.identifier}>: ${message}`}setupListeners(){}applyStyles(){if(!this.constructor.styles)return;const style=this.shadowRoot.querySelector("style");style&&(style.textContent=this.constructor.styles)}getElements(identifiers,elementIdentifier=this._elIdentifier,{context=this}={}){return identifiers.reduce((els,identifier)=>{const subIdentifiers=identifier.split(" ");return subIdentifiers.forEach(_identifier=>{const selector=(()=>{const attributeSelector=subIdentifiers.length>1?"*=":"=",identifierToLookFor=subIdentifiers.length>1?_identifier:identifier;return this.key&&elementIdentifier===this._externalElIdentifier?`[${elementIdentifier}${attributeSelector}"${identifierToLookFor}"][key="${this.key}"]`:`[${elementIdentifier}${attributeSelector}"${identifierToLookFor}"]`})(),elements=Array.from(context.querySelectorAll(selector));els[_identifier]={exists:elements.length>0,elements,element:elements[0],selector}}),els},{})}_upgradeProperty(prop){if(this.hasOwnProperty(prop)){const value=this[prop];delete this[prop],this[prop]=value}}_getElementIdentifiers(){return Array.from(this.querySelectorAll(`[${this._elIdentifier}]`)).map(el=>el.getAttribute(this._elIdentifier))}_getExternalElementIdentifiers(){const selector=this.key?`[${this._externalElIdentifier}][key="${this.key}"]`:`[${this._externalElIdentifier}]`;return Array.from(document.querySelectorAll(selector)).map(el=>el.getAttribute(this._externalElIdentifier))}renderSections(stateSections){if(this.sections.length===0)return;let holdFocusEl=null;document.activeElement&&document.activeElement.id&&(holdFocusEl=document.activeElement.id);const sectionsToRender=this.sections.filter(s=>s.section in stateSections).map(s=>Object.assign({},s,{html:stateSections[s.section]}));if(window.BAO.sectionRenderer.renderMultiple(sectionsToRender),!holdFocusEl)return;const newInput=document.querySelector(`#${CSS.escape(holdFocusEl)}`);newInput&&(newInput.focus(),typeof newInput.select=="function"&&newInput.select())}
13handleCartErrorRender(){if(this.sections.length===0)return;const cartItemsSection=window.BAO.sectionRenderer.pushCartSections.find(section=>section.id==="push-cart");window.BAO.sectionRenderer.fetch(cartItemsSection.section).then(sectionsData=>{window.BAO.sectionRenderer.render({...cartItemsSection,html:sectionsData[cartItemsSection.section]})}).catch(error=>console.error("Error fetching cart items:",error))}log(groupName,...otherItems){this.debug&&(console.group(groupName),otherItems.forEach(item=>console.log(item)),console.groupEnd())}get identifier(){const baseIdentifier=this.hasAttribute("is")?this.getAttribute("is"):this.localName.toLowerCase();return this.key&&this.key.trim().length?`${baseIdentifier}-${this.key.toLowerCase()}`:baseIdentifier}get debug(){return window.theme.isDevTheme}get key(){return this.getAttribute("key")}get hasBeenInitialised(){return this._hasBeenInitialised}get _elIdentifier(){return`data-${this.identifier}-el`}get _externalElIdentifier(){return`data-${this.identifier}-external-el`}get els(){return this.getElements(this._getElementIdentifiers())}get externalEls(){return this.getElements(this._getExternalElementIdentifiers(),this._externalElIdentifier,{context:document})}}return CustomElement};
14//# sourceMappingURL=/cdn/shop/t/1735/assets/bao-custom-element.js.map?v=166085879487581956251782836742

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.