Skip to content
Snippets Groups Projects
Commit de060cc1 authored by Volker Schukai's avatar Volker Schukai :alien:
Browse files

#49

parent 4719e952
No related branches found
No related tags found
No related merge requests found
Showing
with 20 additions and 20 deletions
/** Monster 1.14.0, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */ /** Monster 1.14.1, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
"use strict";import{Monster,Base}from"../types/base.js";import{validateInstance,validateString}from"../types/validate.js";import{getGlobalFunction}from"../types/global.js";import{ProxyObserver}from"../types/proxyobserver.js";const ATTRIBUTEPREFIX="data-monster-";class Assembler extends Base{constructor(e){super(),this.attributePrefix=ATTRIBUTEPREFIX,validateInstance(e,getGlobalFunction("DocumentFragment")),this.fragment=e}setAttributePrefix(e){return validateString(e),this.attributePrefix=e,this}getAttributePrefix(){return this.attributePrefix}createDocumentFragment(e){return void 0===e&&(e=new ProxyObserver({})),validateInstance(e,ProxyObserver),this.fragment.cloneNode(!0)}}Monster.assignToNamespace("Monster.DOM",Assembler);export{Monster,ATTRIBUTEPREFIX,Assembler}; "use strict";import{Monster,Base}from"../types/base.js";import{validateInstance,validateString}from"../types/validate.js";import{getGlobalFunction}from"../types/global.js";import{ProxyObserver}from"../types/proxyobserver.js";const ATTRIBUTEPREFIX="data-monster-";class Assembler extends Base{constructor(e){super(),this.attributePrefix=ATTRIBUTEPREFIX,validateInstance(e,getGlobalFunction("DocumentFragment")),this.fragment=e}setAttributePrefix(e){return validateString(e),this.attributePrefix=e,this}getAttributePrefix(){return this.attributePrefix}createDocumentFragment(e){return void 0===e&&(e=new ProxyObserver({})),validateInstance(e,ProxyObserver),this.fragment.cloneNode(!0)}}Monster.assignToNamespace("Monster.DOM",Assembler);export{Monster,ATTRIBUTEPREFIX,Assembler};
\ No newline at end of file
/** Monster 1.14.0, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */ /** Monster 1.14.1, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
"use strict";import{Monster}from"../namespace.js";import{getGlobalFunction}from"../types/global.js";import{isInstance}from"../types/is.js";import{TokenList}from"../types/tokenlist.js";import{validateInstance,validateString,validateSymbol}from"../types/validate.js";import{ATTRIBUTE_OBJECTLINK}from"./constants.js";function findClosestObjectLink(t){return findClosestByAttribute(t,ATTRIBUTE_OBJECTLINK)}function addToObjectLink(t,e,n){return validateInstance(t,HTMLElement),validateSymbol(e),void 0===t?.[e]&&(t[e]=new Set),addAttributeToken(t,ATTRIBUTE_OBJECTLINK,e.toString()),t[e].add(n),t}function removeObjectLink(t,e){return validateInstance(t,HTMLElement),validateSymbol(e),void 0===t?.[e]||(removeAttributeToken(t,ATTRIBUTE_OBJECTLINK,e.toString()),delete t[e]),t}function hasObjectLink(t,e){return validateInstance(t,HTMLElement),validateSymbol(e),void 0!==t?.[e]&&containsAttributeToken(t,ATTRIBUTE_OBJECTLINK,e.toString())}function getLinkedObjects(t,e){if(validateInstance(t,HTMLElement),validateSymbol(e),void 0===t?.[e])throw new Error("there is no object link for "+e.toString());return t?.[e][Symbol.iterator]()}function toggleAttributeToken(t,e,n){return validateInstance(t,HTMLElement),validateString(n),validateString(e),t.hasAttribute(e)?t.setAttribute(e,new TokenList(t.getAttribute(e)).toggle(n).toString()):t.setAttribute(e,n),t}function addAttributeToken(t,e,n){return validateInstance(t,HTMLElement),validateString(n),validateString(e),t.hasAttribute(e)?t.setAttribute(e,new TokenList(t.getAttribute(e)).add(n).toString()):t.setAttribute(e,n),t}function removeAttributeToken(t,e,n){return validateInstance(t,HTMLElement),validateString(n),validateString(e),t.hasAttribute(e)&&t.setAttribute(e,new TokenList(t.getAttribute(e)).remove(n).toString()),t}function containsAttributeToken(t,e,n){return validateInstance(t,HTMLElement),validateString(n),validateString(e),!!t.hasAttribute(e)&&new TokenList(t.getAttribute(e)).contains(n)}function replaceAttributeToken(t,e,n,i){return validateInstance(t,HTMLElement),validateString(n),validateString(i),validateString(e),t.hasAttribute(e)&&t.setAttribute(e,new TokenList(t.getAttribute(e)).replace(n,i).toString()),t}function clearAttributeTokens(t,e){return validateInstance(t,HTMLElement),validateString(e),t.hasAttribute(e)&&t.setAttribute(e,""),t}function findClosestByAttribute(t,e,n){if(validateInstance(t,getGlobalFunction("HTMLElement")),t.hasAttribute(e)&&t.getAttribute(e)===n)return t;let i=validateString(e);void 0!==n&&(i+="="+validateString(n));t=t.closest("["+i+"]");return t instanceof HTMLElement?t:void 0}Monster.assignToNamespace("Monster.DOM",getLinkedObjects,addToObjectLink,removeObjectLink,findClosestByAttribute,hasObjectLink,clearAttributeTokens,replaceAttributeToken,containsAttributeToken,removeAttributeToken,addAttributeToken,toggleAttributeToken);export{Monster,addToObjectLink,removeObjectLink,hasObjectLink,findClosestByAttribute,clearAttributeTokens,replaceAttributeToken,containsAttributeToken,removeAttributeToken,addAttributeToken,toggleAttributeToken,getLinkedObjects,findClosestObjectLink}; "use strict";import{Monster}from"../namespace.js";import{getGlobalFunction}from"../types/global.js";import{isInstance}from"../types/is.js";import{TokenList}from"../types/tokenlist.js";import{validateInstance,validateString,validateSymbol}from"../types/validate.js";import{ATTRIBUTE_OBJECTLINK}from"./constants.js";function findClosestObjectLink(t){return findClosestByAttribute(t,ATTRIBUTE_OBJECTLINK)}function addToObjectLink(t,e,n){return validateInstance(t,HTMLElement),validateSymbol(e),void 0===t?.[e]&&(t[e]=new Set),addAttributeToken(t,ATTRIBUTE_OBJECTLINK,e.toString()),t[e].add(n),t}function removeObjectLink(t,e){return validateInstance(t,HTMLElement),validateSymbol(e),void 0===t?.[e]||(removeAttributeToken(t,ATTRIBUTE_OBJECTLINK,e.toString()),delete t[e]),t}function hasObjectLink(t,e){return validateInstance(t,HTMLElement),validateSymbol(e),void 0!==t?.[e]&&containsAttributeToken(t,ATTRIBUTE_OBJECTLINK,e.toString())}function getLinkedObjects(t,e){if(validateInstance(t,HTMLElement),validateSymbol(e),void 0===t?.[e])throw new Error("there is no object link for "+e.toString());return t?.[e][Symbol.iterator]()}function toggleAttributeToken(t,e,n){return validateInstance(t,HTMLElement),validateString(n),validateString(e),t.hasAttribute(e)?t.setAttribute(e,new TokenList(t.getAttribute(e)).toggle(n).toString()):t.setAttribute(e,n),t}function addAttributeToken(t,e,n){return validateInstance(t,HTMLElement),validateString(n),validateString(e),t.hasAttribute(e)?t.setAttribute(e,new TokenList(t.getAttribute(e)).add(n).toString()):t.setAttribute(e,n),t}function removeAttributeToken(t,e,n){return validateInstance(t,HTMLElement),validateString(n),validateString(e),t.hasAttribute(e)&&t.setAttribute(e,new TokenList(t.getAttribute(e)).remove(n).toString()),t}function containsAttributeToken(t,e,n){return validateInstance(t,HTMLElement),validateString(n),validateString(e),!!t.hasAttribute(e)&&new TokenList(t.getAttribute(e)).contains(n)}function replaceAttributeToken(t,e,n,i){return validateInstance(t,HTMLElement),validateString(n),validateString(i),validateString(e),t.hasAttribute(e)&&t.setAttribute(e,new TokenList(t.getAttribute(e)).replace(n,i).toString()),t}function clearAttributeTokens(t,e){return validateInstance(t,HTMLElement),validateString(e),t.hasAttribute(e)&&t.setAttribute(e,""),t}function findClosestByAttribute(t,e,n){if(validateInstance(t,getGlobalFunction("HTMLElement")),t.hasAttribute(e)&&t.getAttribute(e)===n)return t;let i=validateString(e);void 0!==n&&(i+="="+validateString(n));t=t.closest("["+i+"]");return t instanceof HTMLElement?t:void 0}Monster.assignToNamespace("Monster.DOM",getLinkedObjects,addToObjectLink,removeObjectLink,findClosestByAttribute,hasObjectLink,clearAttributeTokens,replaceAttributeToken,containsAttributeToken,removeAttributeToken,addAttributeToken,toggleAttributeToken);export{Monster,addToObjectLink,removeObjectLink,hasObjectLink,findClosestByAttribute,clearAttributeTokens,replaceAttributeToken,containsAttributeToken,removeAttributeToken,addAttributeToken,toggleAttributeToken,getLinkedObjects,findClosestObjectLink};
\ No newline at end of file
/** Monster 1.14.0, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */ /** Monster 1.14.1, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
"use strict";import{Monster}from"../namespace.js";const ATTRIBUTE_PREFIX="data-monster-",ATTRIBUTE_OPTIONS=ATTRIBUTE_PREFIX+"options",DEFAULT_THEME="monster",ATTRIBUTE_THEME_PREFIX=ATTRIBUTE_PREFIX+"theme-",ATTRIBUTE_THEME_NAME=ATTRIBUTE_THEME_PREFIX+"name",ATTRIBUTE_UPDATER_ATTRIBUTES=ATTRIBUTE_PREFIX+"attributes",ATTRIBUTE_UPDATER_REPLACE=ATTRIBUTE_PREFIX+"replace",ATTRIBUTE_UPDATER_INSERT=ATTRIBUTE_PREFIX+"insert",ATTRIBUTE_UPDATER_INSERT_REFERENCE=ATTRIBUTE_PREFIX+"insert-reference",ATTRIBUTE_UPDATER_REMOVE=ATTRIBUTE_PREFIX+"remove",ATTRIBUTE_UPDATER_BIND=ATTRIBUTE_PREFIX+"bind",ATTRIBUTE_ROLE=ATTRIBUTE_PREFIX+"role",ATTRIBUTE_OBJECTLINK=ATTRIBUTE_PREFIX+"objectlink",OBJECTLINK_KEY_UPDATER="monsterUpdater";export{Monster,ATTRIBUTE_PREFIX,ATTRIBUTE_OPTIONS,DEFAULT_THEME,ATTRIBUTE_THEME_PREFIX,ATTRIBUTE_ROLE,ATTRIBUTE_THEME_NAME,ATTRIBUTE_UPDATER_ATTRIBUTES,ATTRIBUTE_UPDATER_REPLACE,ATTRIBUTE_UPDATER_INSERT,ATTRIBUTE_UPDATER_INSERT_REFERENCE,ATTRIBUTE_UPDATER_REMOVE,ATTRIBUTE_UPDATER_BIND,ATTRIBUTE_OBJECTLINK,OBJECTLINK_KEY_UPDATER}; "use strict";import{Monster}from"../namespace.js";const ATTRIBUTE_PREFIX="data-monster-",ATTRIBUTE_OPTIONS=ATTRIBUTE_PREFIX+"options",DEFAULT_THEME="monster",ATTRIBUTE_THEME_PREFIX=ATTRIBUTE_PREFIX+"theme-",ATTRIBUTE_THEME_NAME=ATTRIBUTE_THEME_PREFIX+"name",ATTRIBUTE_UPDATER_ATTRIBUTES=ATTRIBUTE_PREFIX+"attributes",ATTRIBUTE_UPDATER_REPLACE=ATTRIBUTE_PREFIX+"replace",ATTRIBUTE_UPDATER_INSERT=ATTRIBUTE_PREFIX+"insert",ATTRIBUTE_UPDATER_INSERT_REFERENCE=ATTRIBUTE_PREFIX+"insert-reference",ATTRIBUTE_UPDATER_REMOVE=ATTRIBUTE_PREFIX+"remove",ATTRIBUTE_UPDATER_BIND=ATTRIBUTE_PREFIX+"bind",ATTRIBUTE_ROLE=ATTRIBUTE_PREFIX+"role",ATTRIBUTE_OBJECTLINK=ATTRIBUTE_PREFIX+"objectlink",OBJECTLINK_KEY_UPDATER="monsterUpdater";export{Monster,ATTRIBUTE_PREFIX,ATTRIBUTE_OPTIONS,DEFAULT_THEME,ATTRIBUTE_THEME_PREFIX,ATTRIBUTE_ROLE,ATTRIBUTE_THEME_NAME,ATTRIBUTE_UPDATER_ATTRIBUTES,ATTRIBUTE_UPDATER_REPLACE,ATTRIBUTE_UPDATER_INSERT,ATTRIBUTE_UPDATER_INSERT_REFERENCE,ATTRIBUTE_UPDATER_REMOVE,ATTRIBUTE_UPDATER_BIND,ATTRIBUTE_OBJECTLINK,OBJECTLINK_KEY_UPDATER};
\ No newline at end of file
/** Monster 1.14.0, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */ /** Monster 1.14.1, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
"use strict";import{extend}from"../data/extend.js";import{isArray}from"../types/is.js";import{OBJECTLINK_KEY_UPDATER}from"./constants.js";import{Monster,CustomElement}from"./customelement.js";const internalSymbol=Symbol("internalSymbol");class CustomControl extends CustomElement{constructor(){super(),"function"==typeof this.attachInternals&&!0===this.getOption("formAssociated")&&(this[internalSymbol]=this.attachInternals())}get defaults(){return Object.assign({},super.defaults,{formAssociated:!0})}static get observedAttributes(){return[]}attributeChangedCallback(t,e,r){var s=this.constructor.observedAttributes();if(!s||isArray(s)&&0<s.length)throw new Error("attributes but no handles have been defined")}static get formAssociated(){return!0}get value(){throw Error("the value getter must be overwritten by the derived class")}set value(t){throw Error("the value setter must be overwritten by the derived class")}setFormValue(t,e){getInternal.call(this).setFormValue(t,e)}setValidity(t,e,r){getInternal.call(this).setValidity(t,e,r)}checkValidity(){return getInternal.call(this)?.checkValidity()}reportValidity(){return getInternal.call(this)?.reportValidity()}get labels(){return getInternal.call(this)?.labels}get name(){return this.getAttribute("name")}get type(){return this.constructor.getTag()}get validity(){return getInternal.call(this)?.validity}get validationMessage(){return getInternal.call(this)?.validationMessage}get willValidate(){return getInternal.call(this)?.willValidate}get states(){return getInternal.call(this)?.states}get form(){return getInternal.call(this)?.form}}function getInternal(){if(!(internalSymbol in this))throw new Error("the ElementInternals is not supported and a polyfill is necessary");return this[internalSymbol]}Monster.assignToNamespace("Monster.DOM",CustomControl);export{Monster,CustomControl}; "use strict";import{extend}from"../data/extend.js";import{isArray}from"../types/is.js";import{OBJECTLINK_KEY_UPDATER}from"./constants.js";import{Monster,CustomElement}from"./customelement.js";const internalSymbol=Symbol("internalSymbol");class CustomControl extends CustomElement{constructor(){super(),"function"==typeof this.attachInternals&&!0===this.getOption("formAssociated")&&(this[internalSymbol]=this.attachInternals())}get defaults(){return Object.assign({},super.defaults,{formAssociated:!0})}static get observedAttributes(){return[]}attributeChangedCallback(t,e,r){var s=this.constructor.observedAttributes();if(!s||isArray(s)&&0<s.length)throw new Error("attributes but no handles have been defined")}static get formAssociated(){return!0}get value(){throw Error("the value getter must be overwritten by the derived class")}set value(t){throw Error("the value setter must be overwritten by the derived class")}setFormValue(t,e){getInternal.call(this).setFormValue(t,e)}setValidity(t,e,r){getInternal.call(this).setValidity(t,e,r)}checkValidity(){return getInternal.call(this)?.checkValidity()}reportValidity(){return getInternal.call(this)?.reportValidity()}get labels(){return getInternal.call(this)?.labels}get name(){return this.getAttribute("name")}get type(){return this.constructor.getTag()}get validity(){return getInternal.call(this)?.validity}get validationMessage(){return getInternal.call(this)?.validationMessage}get willValidate(){return getInternal.call(this)?.willValidate}get states(){return getInternal.call(this)?.states}get form(){return getInternal.call(this)?.form}}function getInternal(){if(!(internalSymbol in this))throw new Error("the ElementInternals is not supported and a polyfill is necessary");return this[internalSymbol]}Monster.assignToNamespace("Monster.DOM",CustomControl);export{Monster,CustomControl};
\ No newline at end of file
/** Monster 1.14.0, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */ /** Monster 1.14.1, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
"use strict";import{Monster,Updater}from"./updater.js";import{extend}from"../data/extend.js";import{Pathfinder}from"../data/pathfinder.js";import{ATTRIBUTE_OPTIONS,OBJECTLINK_KEY_UPDATER}from"./constants.js";import{findDocumentTemplate,Template}from"./template.js";import{addToObjectLink,getLinkedObjects,hasObjectLink}from"./attributes.js";import{getGlobalObject}from"../types/global.js";import{validateFunction,validateObject}from"../types/validate.js";import{isString}from"../types/is.js";import{PROPERTY_KEY_OPTIONS}from"../constants.js";const optionsSymbol=Symbol.for(PROPERTY_KEY_OPTIONS),objectLinkSymbol=Symbol.for(OBJECTLINK_KEY_UPDATER),initMethodSymbol=Symbol("initMethodSymbol"),assembleMethodSymbol=Symbol("assembleMethodSymbol");class CustomElement extends HTMLElement{constructor(){super(),this[optionsSymbol]=extend({},this.defaults,getOptionsFromAttributes.call(this)),this[initMethodSymbol]()}get defaults(){return{shadowMode:"open",delegatesFocus:!0,templates:{main:void 0}}}getOption(t,e){let o;try{o=new Pathfinder(this[optionsSymbol]).getVia(t)}catch(t){}return void 0===o?e:o}setOption(t,e){for(const o of getLinkedObjects(this,Symbol.for(OBJECTLINK_KEY_UPDATER)))for(const i of o)new Pathfinder(this[optionsSymbol]).setVia(t,!1),new Pathfinder(i.getSubject()).setVia(t,e);return this}[initMethodSymbol](){return this}[assembleMethodSymbol](){var t;let e;if(!1!==this.getOption("shadowMode",!1))try{initShadowRoot.call(this),e=this.shadowRoot.childNodes}catch(t){}e instanceof NodeList||(initHtmlContent.call(this),e=this.childNodes);const o=new Set;addToObjectLink(this,objectLinkSymbol,o);for([,t]of Object.entries(e))if(t instanceof HTMLElement){const i=new Updater(t,this[optionsSymbol]);o.add(i),i.run().then(()=>{i.enableEventProcessing()})}return this}connectedCallback(){let t=this;hasObjectLink(t,objectLinkSymbol)||setTimeout(()=>{t[assembleMethodSymbol]()},0)}disconnectedCallback(){}adoptedCallback(){}attributeChangedCallback(t,e,o){}static getTag(){throw new Error("the method getTag must be overwritten by the derived class.")}static getCSSStyleSheet(){}}function getOptionsFromAttributes(){if(this.hasAttribute(ATTRIBUTE_OPTIONS))try{var t=JSON.parse(this.getAttribute(ATTRIBUTE_OPTIONS));return validateObject(t),t}catch(t){throw new Error("the options attribute "+ATTRIBUTE_OPTIONS+" does not contain a valid json definition (actual: "+this.getAttribute(ATTRIBUTE_OPTIONS)+").")}return{}}function initHtmlContent(){try{let t=findDocumentTemplate(this.constructor.getTag());this.appendChild(t.createDocumentFragment())}catch(t){var e=this.getOption("templates.main","");isString(e)&&0<e.length&&(this.innerHTML=e)}return this}function initShadowRoot(){let t,e;try{t=findDocumentTemplate(this.constructor.getTag())}catch(t){if(e=this.getOption("templates.main",""),!isString(e)||void 0===e||""===e)throw new Error("html is not set.")}this.attachShadow({mode:this.getOption("shadowMode","open"),delegatesFocus:this.getOption("delegatesFocus",!0)});var o=this.constructor.getCSSStyleSheet();return o instanceof CSSStyleSheet&&(this.shadowRoot.adoptedStyleSheets=[o]),t instanceof Template?this.shadowRoot.appendChild(t.createDocumentFragment()):this.shadowRoot.innerHTML=e,this}function registerCustomElement(t){validateFunction(t),getGlobalObject("customElements").define(t.getTag(),t)}Monster.assignToNamespace("Monster.DOM",CustomElement,registerCustomElement);export{Monster,registerCustomElement,CustomElement,initMethodSymbol,assembleMethodSymbol}; "use strict";import{Monster,Updater}from"./updater.js";import{extend}from"../data/extend.js";import{Pathfinder}from"../data/pathfinder.js";import{ATTRIBUTE_OPTIONS,OBJECTLINK_KEY_UPDATER}from"./constants.js";import{findDocumentTemplate,Template}from"./template.js";import{addToObjectLink,getLinkedObjects,hasObjectLink}from"./attributes.js";import{getGlobalObject}from"../types/global.js";import{validateFunction,validateObject}from"../types/validate.js";import{isString}from"../types/is.js";import{PROPERTY_KEY_OPTIONS}from"../constants.js";const optionsSymbol=Symbol.for(PROPERTY_KEY_OPTIONS),objectLinkSymbol=Symbol.for(OBJECTLINK_KEY_UPDATER),initMethodSymbol=Symbol("initMethodSymbol"),assembleMethodSymbol=Symbol("assembleMethodSymbol");class CustomElement extends HTMLElement{constructor(){super(),this[optionsSymbol]=extend({},this.defaults,getOptionsFromAttributes.call(this)),this[initMethodSymbol]()}get defaults(){return{shadowMode:"open",delegatesFocus:!0,templates:{main:void 0}}}getOption(t,e){let o;try{o=new Pathfinder(this[optionsSymbol]).getVia(t)}catch(t){}return void 0===o?e:o}setOption(t,e){for(const o of getLinkedObjects(this,Symbol.for(OBJECTLINK_KEY_UPDATER)))for(const i of o)new Pathfinder(this[optionsSymbol]).setVia(t,!1),new Pathfinder(i.getSubject()).setVia(t,e);return this}[initMethodSymbol](){return this}[assembleMethodSymbol](){var t;let e;if(!1!==this.getOption("shadowMode",!1))try{initShadowRoot.call(this),e=this.shadowRoot.childNodes}catch(t){}e instanceof NodeList||(initHtmlContent.call(this),e=this.childNodes);const o=new Set;addToObjectLink(this,objectLinkSymbol,o);for([,t]of Object.entries(e))if(t instanceof HTMLElement){const i=new Updater(t,this[optionsSymbol]);o.add(i),i.run().then(()=>{i.enableEventProcessing()})}return this}connectedCallback(){let t=this;hasObjectLink(t,objectLinkSymbol)||setTimeout(()=>{t[assembleMethodSymbol]()},0)}disconnectedCallback(){}adoptedCallback(){}attributeChangedCallback(t,e,o){}static getTag(){throw new Error("the method getTag must be overwritten by the derived class.")}static getCSSStyleSheet(){}}function getOptionsFromAttributes(){if(this.hasAttribute(ATTRIBUTE_OPTIONS))try{var t=JSON.parse(this.getAttribute(ATTRIBUTE_OPTIONS));return validateObject(t),t}catch(t){throw new Error("the options attribute "+ATTRIBUTE_OPTIONS+" does not contain a valid json definition (actual: "+this.getAttribute(ATTRIBUTE_OPTIONS)+").")}return{}}function initHtmlContent(){try{let t=findDocumentTemplate(this.constructor.getTag());this.appendChild(t.createDocumentFragment())}catch(t){var e=this.getOption("templates.main","");isString(e)&&0<e.length&&(this.innerHTML=e)}return this}function initShadowRoot(){let t,e;try{t=findDocumentTemplate(this.constructor.getTag())}catch(t){if(e=this.getOption("templates.main",""),!isString(e)||void 0===e||""===e)throw new Error("html is not set.")}this.attachShadow({mode:this.getOption("shadowMode","open"),delegatesFocus:this.getOption("delegatesFocus",!0)});var o=this.constructor.getCSSStyleSheet();return o instanceof CSSStyleSheet&&(this.shadowRoot.adoptedStyleSheets=[o]),t instanceof Template?this.shadowRoot.appendChild(t.createDocumentFragment()):this.shadowRoot.innerHTML=e,this}function registerCustomElement(t){validateFunction(t),getGlobalObject("customElements").define(t.getTag(),t)}Monster.assignToNamespace("Monster.DOM",CustomElement,registerCustomElement);export{Monster,registerCustomElement,CustomElement,initMethodSymbol,assembleMethodSymbol};
\ No newline at end of file
/** Monster 1.14.0, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */ /** Monster 1.14.1, © 2021 schukai GmbH, Released under the AGPL 3.0 License. */
"use strict";import{Monster,validateInstance,validateString}from"../types/validate.js";import{findClosestByAttribute}from"./attributes.js";import{getDocument}from"./util.js";function fireEvent(e,t){var n;getDocument();if(e instanceof HTMLElement)"click"!==t?(n=new Event(validateString(t),{bubbles:!0,cancelable:!0}),e.dispatchEvent(n)):e.click();else{if(!(e instanceof HTMLCollection||e instanceof NodeList))throw new TypeError("value is not an instance of HTMLElement or HTMLCollection");for(var o of e)fireEvent(o,t)}}function findTargetElementFromEvent(e,t,n){if(validateInstance(e,Event),"function"!=typeof e.composedPath)throw new Error("unsupported event");e=e.composedPath()?.[0];if(e instanceof HTMLElement)return findClosestByAttribute(e,t,n)}Monster.assignToNamespace("Monster.DOM",findTargetElementFromEvent,fireEvent);export{Monster,findTargetElementFromEvent,fireEvent}; "use strict";import{Monster,validateInstance,validateString}from"../types/validate.js";import{findClosestByAttribute}from"./attributes.js";import{getDocument}from"./util.js";function fireEvent(e,t){var n;getDocument();if(e instanceof HTMLElement)"click"!==t?(n=new Event(validateString(t),{bubbles:!0,cancelable:!0}),e.dispatchEvent(n)):e.click();else{if(!(e instanceof HTMLCollection||e instanceof NodeList))throw new TypeError("value is not an instance of HTMLElement or HTMLCollection");for(var o of e)fireEvent(o,t)}}function findTargetElementFromEvent(e,t,n){if(validateInstance(e,Event),"function"!=typeof e.composedPath)throw new Error("unsupported event");e=e.composedPath()?.[0];if(e instanceof HTMLElement)return findClosestByAttribute(e,t,n)}Monster.assignToNamespace("Monster.DOM",findTargetElementFromEvent,fireEvent);export{Monster,findTargetElementFromEvent,fireEvent};
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment