shorter-js
Advanced tools
Comparing version 0.2.24 to 0.2.25-alpha1
/*! | ||
* shorter-js v0.2.24 (https://github.com/thednp/shorter-js) | ||
* shorter-js v0.2.25alpha1 (https://github.com/thednp/shorter-js) | ||
* Copyright 2019-2022 © dnp_theme | ||
@@ -876,5 +876,5 @@ * Licensed under MIT (https://github.com/thednp/shorter-js/blob/master/LICENSE) | ||
/** | ||
* Add class to Element.classList | ||
* Add class to `HTMLElement.classList`. | ||
* | ||
* @param {Element} element target | ||
* @param {HTMLElement} element target | ||
* @param {string} classNAME to add | ||
@@ -887,5 +887,5 @@ */ | ||
/** | ||
* Remove class from Element.classList | ||
* Remove class from `HTMLElement.classList`. | ||
* | ||
* @param {Element} element target | ||
* @param {HTMLElement} element target | ||
* @param {string} classNAME to remove | ||
@@ -898,5 +898,5 @@ */ | ||
/** | ||
* Check class in Element.classList | ||
* Check class in `HTMLElement.classList`. | ||
* | ||
* @param {Element} element target | ||
* @param {HTMLElement} element target | ||
* @param {string} classNAME to check | ||
@@ -1008,2 +1008,3 @@ * @return {boolean} | ||
/** @type {Map<string, Map<HTMLElement, SHORTER.Component>>} */ | ||
const componentData = new Map(); | ||
@@ -1019,7 +1020,7 @@ /** | ||
* @param {string} component the component's name or a unique key | ||
* @param {any} instance the component instance | ||
* @param {SHORTER.Component} instance the component instance | ||
*/ | ||
set: (target, component, instance) => { | ||
const element = querySelector(target); | ||
if (!isHTMLElement(element)) return; | ||
if (!element || !isHTMLElement(element)) return; | ||
@@ -1031,2 +1032,3 @@ if (!componentData.has(component)) { | ||
const instanceMap = componentData.get(component); | ||
// @ts-ignore - not undefined, but defined right above | ||
instanceMap.set(element, instance); | ||
@@ -1038,3 +1040,3 @@ }, | ||
* @param {string} component the component's name or a unique key | ||
* @returns {any?} all the component instances | ||
* @returns {Map<HTMLElement, SHORTER.Component> | null | undefined} all the component instances | ||
*/ | ||
@@ -1052,3 +1054,3 @@ getAllFor: (component) => { | ||
* @param {string} component the component's name or a unique key | ||
* @returns {any?} the instance | ||
* @returns {SHORTER.Component | null | undefined} the instance | ||
*/ | ||
@@ -1059,3 +1061,3 @@ get: (target, component) => { | ||
const allForC = Data.getAllFor(component); | ||
if (allForC && isHTMLElement(element) && allForC.has(element)) { | ||
if (allForC && element && isHTMLElement(element) && allForC.has(element)) { | ||
return allForC.get(element); | ||
@@ -1073,5 +1075,5 @@ } | ||
const element = querySelector(target); | ||
if (!componentData.has(component) || !element) return; | ||
const instanceMap = componentData.get(component); | ||
if (!instanceMap || !element) return; | ||
const instanceMap = componentData.get(component); | ||
instanceMap.delete(element); | ||
@@ -1087,5 +1089,3 @@ | ||
* An alias for `Data.get()`. | ||
* @param {HTMLElement | string} target target element | ||
* @param {string} component the component's name or a unique key | ||
* @returns {Record<string, any>?} the request result | ||
* @type {SHORTER.getInstance<any>} | ||
*/ | ||
@@ -1705,3 +1705,3 @@ const getInstance = (target, component) => Data.get(target, component); | ||
var version = "0.2.24"; | ||
var version = "0.2.25alpha1"; | ||
@@ -1708,0 +1708,0 @@ // @ts-ignore |
@@ -1,2 +0,2 @@ | ||
// shorter-js v0.2.24 | dnp_theme © 2022 | MIT-License | ||
const e="onmouseleave"in document?["mouseenter","mouseleave"]:["mouseover","mouseout"],t="webkitAnimation"in document.head.style?"webkitAnimationDuration":"animationDuration",n="webkitAnimation"in document.head.style?"webkitAnimationDelay":"animationDelay",i="webkitAnimation"in document.head.style?"webkitAnimationName":"animationName",o="webkitAnimation"in document.head.style?"webkitAnimationEnd":"animationend",a="webkitTransition"in document.head.style?"webkitTransitionDuration":"transitionDuration",r="webkitTransition"in document.head.style?"webkitTransitionDelay":"transitionDelay",s="webkitTransition"in document.head.style?"webkitTransitionEnd":"transitionend",c="webkitTransition"in document.head.style?"webkitTransitionProperty":"transitionProperty",u=/iPhone|iPad|iPod|Android/i;let l=!1;l=navigator.userAgentData?navigator.userAgentData.brands.some(e=>u.test(e.brand)):u.test(navigator.userAgent);const m=l,d=navigator.userAgentData,g=/(iPhone|iPod|iPad)/,v=d?d.brands.some(e=>g.test(e.brand)):g.test(navigator.userAgent),E="webkitPerspective"in document.head.style||"perspective"in document.head.style;function p(e,t,n,i){const o=i||!1;e.addEventListener(t,n,o)}function y(e,t,n,i){const o=i||!1;e.removeEventListener(t,n,o)}function b(e,t,n,i){p(e,t,(function o(a){a.target===e&&(n.apply(e,[a]),y(e,t,o,i))}),i)}const h=(()=>{let e=!1;try{const t=Object.defineProperty({},"passive",{get:()=>(e=!0,e)});b(document,"DOMContentLoaded",()=>{},t)}catch(e){throw Error("Passive events are not supported")}return e})(),f="webkitTransform"in document.head.style||"transform"in document.head.style,w="ontouchstart"in window||"msMaxTouchPoints"in navigator,k="webkitAnimation"in document.head.style||"animation"in document.head.style,A="webkitTransition"in document.head.style||"transition"in document.head.style;const L=e=>"object"==typeof e&&e instanceof HTMLElement;function D(e,t){const n=t&&L(t)?t:document;return"object"==typeof e?e:n.querySelector(e)}const T=new Map,N={set:(e,t,n,i)=>{const o=D(e);if(L(o))if(i&&i.length){T.has(o)||T.set(o,new Map);T.get(o).set(i,setTimeout(t,n))}else T.set(o,setTimeout(t,n))},get:(e,t)=>{const n=D(e);if(!L(n))return null;if(t&&t.length){T.has(n)||T.set(n,new Map);const e=T.get(n);if(e.has(t))return e.get(t)}else if(T.has(n))return T.get(n);return null},clear:(e,t)=>{const n=D(e);if(L(n)&&T.has(n))if(t&&t.length){const e=T.get(n);e&&e.has(t)&&(clearTimeout(e.get(t)),e.delete(t))}else T.has(n)&&(clearTimeout(T.get(n)),T.delete(n))}},C=new Map,z={set:(e,t,n)=>{const i=D(e);if(!L(i))return;C.has(t)||C.set(t,new Map);C.get(t).set(i,n)},getAllFor:e=>C.has(e)?C.get(e):null,get:(e,t)=>{const n=D(e),i=z.getAllFor(t);return i&&L(n)&&i.has(n)?i.get(n):null},remove:(e,t)=>{const n=D(e);if(!C.has(t)||!n)return;const i=C.get(t);i.delete(n),0===i.size&&C.delete(t)}};function M(e,t){const n=getComputedStyle(e);return t&&t in n?n.getPropertyValue(t):""}function O(e){const t=M(e,"animationName"),n=M(e,"animationDelay"),i=n.includes("ms")?1:1e3,o=t&&"none"!==t?parseFloat(n)*i:0;return Number.isNaN(o)?0:o}function S(e){const t=M(e,"animationName"),n=M(e,"animationDuration"),i=n.includes("ms")?1:1e3,o=t&&"none"!==t?parseFloat(n)*i:0;return Number.isNaN(o)?0:o}function I(e){const t=M(e,i),o=M(e,n),a=o.includes("ms")?1:1e3,r=k&&t&&"none"!==t?parseFloat(o)*a:0;return Number.isNaN(r)?0:r}function P(e){const n=M(e,i),o=M(e,t),a=o.includes("ms")?1:1e3,r=k&&n&&"none"!==n?parseFloat(o)*a:0;return Number.isNaN(r)?0:r}function H(e){const t=M(e,"transitionProperty"),n=M(e,"transitionDelay"),i=n.includes("ms")?1:1e3,o=t&&"none"!==t?parseFloat(n)*i:0;return Number.isNaN(o)?0:o}function F(e){const t=M(e,"transitionProperty"),n=M(e,"transitionDuration"),i=n.includes("ms")?1:1e3,o=t&&"none"!==t?parseFloat(n)*i:0;return Number.isNaN(o)?0:o}function B(e){const t=M(e,c),n=M(e,r),i=n.includes("ms")?1:1e3,o=A&&t&&"none"!==t?parseFloat(n)*i:0;return Number.isNaN(o)?0:o}function x(e){const t=M(e,c),n=M(e,a),i=n.includes("ms")?1:1e3,o=A&&t&&"none"!==t?parseFloat(n)*i:0;return Number.isNaN(o)?0:o}function j(e){return"true"===e||"false"!==e&&(Number.isNaN(+e)?""===e||"null"===e?null:e:+e)}const Q=e=>Object.keys(e);const R=(e,t)=>Object.assign(e,t);const V={ariaChecked:"aria-checked",ariaDescribedBy:"aria-describedby",ariaExpanded:"aria-expanded",ariaHidden:"aria-hidden",ariaLabel:"aria-label",ariaLabelledBy:"aria-labelledby",ariaModal:"aria-modal",ariaPressed:"aria-pressed",ariaSelected:"aria-selected",nativeEvents:["click","dblclick","mouseup","mousedown","contextmenu","mousewheel","DOMMouseScroll","mouseover","mouseout","mousemove","selectstart","selectend","keydown","keypress","keyup","orientationchange","touchstart","touchmove","touchend","touchcancel","pointercancel","pointerdown","pointerleave","pointermove","pointerup","gesturestart","gesturechange","gestureend","focus","blur","change","reset","select","submit","focusin","focusout","load","unload","beforeunload","resize","move","DOMContentLoaded","readystatechange","error","abort","scroll"],abortEvent:"abort",blurEvent:"blur",moveEvent:"move",changeEvent:"change",errorEvent:"error",resetEvent:"reset",resizeEvent:"resize",scrollEvent:"scroll",submitEvent:"submit",loadEvent:"load",unloadEvent:"unload",readystatechangeEvent:"readystatechange",beforeunloadEvent:"beforeunload",orientationchangeEvent:"orientationchange",contextmenuEvent:"contextmenu",DOMContentLoadedEvent:"DOMContentLoaded",DOMMouseScrollEvent:"DOMMouseScroll",selectEvent:"select",selectendEvent:"selectend",selectstartEvent:"selectstart",mouseClickEvents:{down:"mousedown",up:"mouseup"},mouseclickEvent:"click",mousedblclickEvent:"dblclick",mousedownEvent:"mousedown",mouseupEvent:"mouseup",mousehoverEvent:"hover",mouseHoverEvents:e,mouseenterEvent:"mouseenter",mouseleaveEvent:"mouseleave",mouseinEvent:"mousein",mouseoutEvent:"mouseout",mousemoveEvent:"mousemove",mousewheelEvent:"mousewheel",mouseSwipeEvents:{start:"mousedown",end:"mouseup",move:"mousemove",cancel:"mouseleave"},touchEvents:{start:"touchstart",end:"touchend",move:"touchmove",cancel:"touchcancel"},touchstartEvent:"touchstart",touchmoveEvent:"touchmove",touchcancelEvent:"touchcancel",touchendEvent:"touchend",pointercancelEvent:"pointercancel",pointerdownEvent:"pointerdown",pointerleaveEvent:"pointerleave",pointermoveEvent:"pointermove",pointerupEvent:"pointerup",focusEvents:{in:"focusin",out:"focusout"},focusEvent:"focus",focusinEvent:"focusin",focusoutEvent:"focusout",gesturechangeEvent:"gesturechange",gestureendEvent:"gestureend",gesturestartEvent:"gesturestart",bezierEasings:{linear:"linear",easingSinusoidalIn:"cubic-bezier(0.47,0,0.745,0.715)",easingSinusoidalOut:"cubic-bezier(0.39,0.575,0.565,1)",easingSinusoidalInOut:"cubic-bezier(0.445,0.05,0.55,0.95)",easingQuadraticIn:"cubic-bezier(0.550,0.085,0.680,0.530)",easingQuadraticOut:"cubic-bezier(0.250,0.460,0.450,0.940)",easingQuadraticInOut:"cubic-bezier(0.455,0.030,0.515,0.955)",easingCubicIn:"cubic-bezier(0.55,0.055,0.675,0.19)",easingCubicOut:"cubic-bezier(0.215,0.61,0.355,1)",easingCubicInOut:"cubic-bezier(0.645,0.045,0.355,1)",easingQuarticIn:"cubic-bezier(0.895,0.03,0.685,0.22)",easingQuarticOut:"cubic-bezier(0.165,0.84,0.44,1)",easingQuarticInOut:"cubic-bezier(0.77,0,0.175,1)",easingQuinticIn:"cubic-bezier(0.755,0.05,0.855,0.06)",easingQuinticOut:"cubic-bezier(0.23,1,0.32,1)",easingQuinticInOut:"cubic-bezier(0.86,0,0.07,1)",easingExponentialIn:"cubic-bezier(0.95,0.05,0.795,0.035)",easingExponentialOut:"cubic-bezier(0.19,1,0.22,1)",easingExponentialInOut:"cubic-bezier(1,0,0,1)",easingCircularIn:"cubic-bezier(0.6,0.04,0.98,0.335)",easingCircularOut:"cubic-bezier(0.075,0.82,0.165,1)",easingCircularInOut:"cubic-bezier(0.785,0.135,0.15,0.86)",easingBackIn:"cubic-bezier(0.6,-0.28,0.735,0.045)",easingBackOut:"cubic-bezier(0.175,0.885,0.32,1.275)",easingBackInOut:"cubic-bezier(0.68,-0.55,0.265,1.55)"},animationDuration:"animationDuration",animationDurationLegacy:t,animationDelay:"animationDelay",animationDelayLegacy:n,animationName:"animationName",animationNameLegacy:i,animationEndEvent:"animationend",animationEndEventLegacy:o,transitionDuration:"transitionDuration",transitionDurationLegacy:a,transitionDelay:"transitionDelay",transitionDelayLegacy:r,transitionEndEvent:"transitionend",transitionEndEventLegacy:s,transitionProperty:"transitionProperty",transitionPropertyLegacy:c,isMobile:m,isApple:v,support3DTransform:E,supportPassive:h,supportTransform:f,supportTouch:w,supportAnimation:k,supportTransition:A,addEventListener:"addEventListener",removeEventListener:"removeEventListener",keyboardEventKeys:{Backspace:"Backspace",Tab:"Tab",Enter:"Enter",Shift:"Shift",Control:"Control",Alt:"Alt",Pause:"Pause",CapsLock:"CapsLock",Escape:"Escape",Scape:"Space",ArrowLeft:"ArrowLeft",ArrowUp:"ArrowUp",ArrowRight:"ArrowRight",ArrowDown:"ArrowDown",Insert:"Insert",Delete:"Delete",Meta:"Meta",ContextMenu:"ContextMenu",ScrollLock:"ScrollLock"},keydownEvent:"keydown",keypressEvent:"keypress",keyupEvent:"keyup",keyAlt:"Alt",keyArrowDown:"ArrowDown",keyArrowLeft:"ArrowLeft",keyArrowRight:"ArrowRight",keyArrowUp:"ArrowUp",keyBackspace:"Backspace",keyCapsLock:"CapsLock",keyControl:"Control",keyDelete:"Delete",keyEnter:"Enter",keyEscape:"Escape",keyInsert:"Insert",keyMeta:"Meta",keyPause:"Pause",keyScrollLock:"ScrollLock",keyShift:"Shift",keySpace:"Space",keyTab:"Tab",offsetHeight:"offsetHeight",offsetWidth:"offsetWidth",scrollHeight:"scrollHeight",scrollWidth:"scrollWidth",userAgentData:"userAgentData",addClass:function(e,t){e.classList.add(t)},removeClass:function(e,t){e.classList.remove(t)},hasClass:function(e,t){return e.classList.contains(t)},on:p,off:y,one:b,Data:z,Timer:N,getInstance:(e,t)=>z.get(e,t),emulateAnimationEnd:function(e,t){let n=0;const i=new Event("animationend"),o=S(e),a=O(e);if(o){const r=i=>{i.target===e&&(t.apply(e,[i]),e.removeEventListener("animationend",r),n=1)};e.addEventListener("animationend",r),setTimeout(()=>{n||e.dispatchEvent(i)},o+a+17)}else t.apply(e,[i])},emulateAnimationEndLegacy:function(e,t){let n=0;const i=new Event(o),a=P(e),r=I(e);if(k&&a){const s=i=>{i.target===e&&(t.apply(e,[i]),e.removeEventListener(o,s),n=1)};e.addEventListener(o,s),setTimeout(()=>{n||e.dispatchEvent(i)},a+r+17)}else t.apply(e,[i])},emulateTransitionEnd:function(e,t){let n=0;const i=new Event("transitionend"),o=F(e),a=H(e);if(o){const r=i=>{i.target===e&&(t.apply(e,[i]),e.removeEventListener("transitionend",r),n=1)};e.addEventListener("transitionend",r),setTimeout(()=>{n||e.dispatchEvent(i)},o+a+17)}else t.apply(e,[i])},emulateTransitionEndLegacy:function(e,t){let n=0;const i=new Event(s),o=x(e),a=B(e);if(A&&o){const r=i=>{i.target===e&&(t.apply(e,[i]),e.removeEventListener(s,r),n=1)};e.addEventListener(s,r),setTimeout(()=>{n||e.dispatchEvent(i)},o+a+17)}else t.apply(e,[i])},isElementInScrollRange:function(e){const t=e.getBoundingClientRect(),n=window.innerHeight||document.documentElement.clientHeight;return t.top<=n&&t.bottom>=0},isElementInViewport:function(e){const t=e.getBoundingClientRect();return t.top>=0&&t.left>=0&&t.bottom<=(window.innerHeight||document.documentElement.clientHeight)&&t.right<=(window.innerWidth||document.documentElement.clientWidth)},passiveHandler:!!h&&{passive:!0},getElementAnimationDuration:S,getElementAnimationDurationLegacy:P,getElementAnimationDelay:O,getElementAnimationDelayLegacy:I,getElementTransitionDuration:F,getElementTransitionDurationLegacy:x,getElementTransitionDelay:H,getElementTransitionDelayLegacy:B,isArray:e=>Array.isArray(e),isString:e=>e&&"string"==typeof e,isElement:e=>e&&e instanceof Element,isHTMLElement:L,isNodeList:e=>e instanceof NodeList,isHTMLCollection:e=>e instanceof HTMLCollection,isElementsArray:e=>Array.isArray(e)&&e.every(e=>L(e)),isMedia:e=>"object"==typeof e&&[SVGElement,HTMLImageElement,HTMLVideoElement].some(t=>e instanceof t),isRTL:()=>"rtl"===document.documentElement.dir,queryElement:function(e,t){return D(e,t)},querySelector:D,querySelectorAll:function(e,t){return(t&&L(t)?t:document).querySelectorAll(e)},getElementsByClassName:function(e,t){return(t&&L(t)?t:document).getElementsByClassName(e)},getElementsByTagName:function(e,t){return(t&&L(t)?t:document).getElementsByTagName(e)},normalizeValue:j,normalizeOptions:function(e,t,n,i){const o={...e.dataset},a={},r={};return Q(o).forEach(e=>{const t=i&&e.includes(i)?e.replace(i,"").replace(/[A-Z]/,e=>e.toLowerCase()):e;r[t]=j(o[e])}),Q(n).forEach(e=>{n[e]=j(n[e])}),Q(t).forEach(e=>{a[e]=e in n?n[e]:e in r?r[e]:t[e]}),a},tryWrapper:function(e,t){try{e()}catch(e){throw TypeError(`${t} ${e}`)}},reflow:e=>e.offsetHeight,ArrayFrom:e=>Array.from(e),Float32ArrayFrom:e=>Float32Array.from(Array.from(e)),Float64ArrayFrom:e=>Float64Array.from(Array.from(e)),ObjectAssign:R,ObjectKeys:Q,ObjectValues:e=>Object.values(e),getElementStyle:M,setElementStyle:(e,t)=>R(e.style,t),getAttribute:(e,t)=>e.getAttribute(t),setAttribute:(e,t,n)=>e.setAttribute(t,n),removeAttribute:(e,t)=>e.removeAttribute(t),Version:"0.2.24"};export{V as default}; | ||
// shorter-js v0.2.25alpha1 | dnp_theme © 2022 | MIT-License | ||
const e="onmouseleave"in document?["mouseenter","mouseleave"]:["mouseover","mouseout"],t="webkitAnimation"in document.head.style?"webkitAnimationDuration":"animationDuration",n="webkitAnimation"in document.head.style?"webkitAnimationDelay":"animationDelay",i="webkitAnimation"in document.head.style?"webkitAnimationName":"animationName",o="webkitAnimation"in document.head.style?"webkitAnimationEnd":"animationend",a="webkitTransition"in document.head.style?"webkitTransitionDuration":"transitionDuration",r="webkitTransition"in document.head.style?"webkitTransitionDelay":"transitionDelay",s="webkitTransition"in document.head.style?"webkitTransitionEnd":"transitionend",c="webkitTransition"in document.head.style?"webkitTransitionProperty":"transitionProperty",u=/iPhone|iPad|iPod|Android/i;let l=!1;l=navigator.userAgentData?navigator.userAgentData.brands.some(e=>u.test(e.brand)):u.test(navigator.userAgent);const m=l,d=navigator.userAgentData,g=/(iPhone|iPod|iPad)/,v=d?d.brands.some(e=>g.test(e.brand)):g.test(navigator.userAgent),p="webkitPerspective"in document.head.style||"perspective"in document.head.style;function E(e,t,n,i){const o=i||!1;e.addEventListener(t,n,o)}function y(e,t,n,i){const o=i||!1;e.removeEventListener(t,n,o)}function b(e,t,n,i){E(e,t,(function o(a){a.target===e&&(n.apply(e,[a]),y(e,t,o,i))}),i)}const h=(()=>{let e=!1;try{const t=Object.defineProperty({},"passive",{get:()=>(e=!0,e)});b(document,"DOMContentLoaded",()=>{},t)}catch(e){throw Error("Passive events are not supported")}return e})(),f="webkitTransform"in document.head.style||"transform"in document.head.style,w="ontouchstart"in window||"msMaxTouchPoints"in navigator,k="webkitAnimation"in document.head.style||"animation"in document.head.style,A="webkitTransition"in document.head.style||"transition"in document.head.style;const L=e=>"object"==typeof e&&e instanceof HTMLElement;function D(e,t){const n=t&&L(t)?t:document;return"object"==typeof e?e:n.querySelector(e)}const T=new Map,N={set:(e,t,n,i)=>{const o=D(e);if(L(o))if(i&&i.length){T.has(o)||T.set(o,new Map);T.get(o).set(i,setTimeout(t,n))}else T.set(o,setTimeout(t,n))},get:(e,t)=>{const n=D(e);if(!L(n))return null;if(t&&t.length){T.has(n)||T.set(n,new Map);const e=T.get(n);if(e.has(t))return e.get(t)}else if(T.has(n))return T.get(n);return null},clear:(e,t)=>{const n=D(e);if(L(n)&&T.has(n))if(t&&t.length){const e=T.get(n);e&&e.has(t)&&(clearTimeout(e.get(t)),e.delete(t))}else T.has(n)&&(clearTimeout(T.get(n)),T.delete(n))}},C=new Map,z={set:(e,t,n)=>{const i=D(e);if(!i||!L(i))return;C.has(t)||C.set(t,new Map);C.get(t).set(i,n)},getAllFor:e=>C.has(e)?C.get(e):null,get:(e,t)=>{const n=D(e),i=z.getAllFor(t);return i&&n&&L(n)&&i.has(n)?i.get(n):null},remove:(e,t)=>{const n=D(e),i=C.get(t);i&&n&&(i.delete(n),0===i.size&&C.delete(t))}};function M(e,t){const n=getComputedStyle(e);return t&&t in n?n.getPropertyValue(t):""}function O(e){const t=M(e,"animationName"),n=M(e,"animationDelay"),i=n.includes("ms")?1:1e3,o=t&&"none"!==t?parseFloat(n)*i:0;return Number.isNaN(o)?0:o}function S(e){const t=M(e,"animationName"),n=M(e,"animationDuration"),i=n.includes("ms")?1:1e3,o=t&&"none"!==t?parseFloat(n)*i:0;return Number.isNaN(o)?0:o}function I(e){const t=M(e,i),o=M(e,n),a=o.includes("ms")?1:1e3,r=k&&t&&"none"!==t?parseFloat(o)*a:0;return Number.isNaN(r)?0:r}function P(e){const n=M(e,i),o=M(e,t),a=o.includes("ms")?1:1e3,r=k&&n&&"none"!==n?parseFloat(o)*a:0;return Number.isNaN(r)?0:r}function H(e){const t=M(e,"transitionProperty"),n=M(e,"transitionDelay"),i=n.includes("ms")?1:1e3,o=t&&"none"!==t?parseFloat(n)*i:0;return Number.isNaN(o)?0:o}function F(e){const t=M(e,"transitionProperty"),n=M(e,"transitionDuration"),i=n.includes("ms")?1:1e3,o=t&&"none"!==t?parseFloat(n)*i:0;return Number.isNaN(o)?0:o}function B(e){const t=M(e,c),n=M(e,r),i=n.includes("ms")?1:1e3,o=A&&t&&"none"!==t?parseFloat(n)*i:0;return Number.isNaN(o)?0:o}function x(e){const t=M(e,c),n=M(e,a),i=n.includes("ms")?1:1e3,o=A&&t&&"none"!==t?parseFloat(n)*i:0;return Number.isNaN(o)?0:o}function j(e){return"true"===e||"false"!==e&&(Number.isNaN(+e)?""===e||"null"===e?null:e:+e)}const Q=e=>Object.keys(e);const R=(e,t)=>Object.assign(e,t);const V={ariaChecked:"aria-checked",ariaDescribedBy:"aria-describedby",ariaExpanded:"aria-expanded",ariaHidden:"aria-hidden",ariaLabel:"aria-label",ariaLabelledBy:"aria-labelledby",ariaModal:"aria-modal",ariaPressed:"aria-pressed",ariaSelected:"aria-selected",nativeEvents:["click","dblclick","mouseup","mousedown","contextmenu","mousewheel","DOMMouseScroll","mouseover","mouseout","mousemove","selectstart","selectend","keydown","keypress","keyup","orientationchange","touchstart","touchmove","touchend","touchcancel","pointercancel","pointerdown","pointerleave","pointermove","pointerup","gesturestart","gesturechange","gestureend","focus","blur","change","reset","select","submit","focusin","focusout","load","unload","beforeunload","resize","move","DOMContentLoaded","readystatechange","error","abort","scroll"],abortEvent:"abort",blurEvent:"blur",moveEvent:"move",changeEvent:"change",errorEvent:"error",resetEvent:"reset",resizeEvent:"resize",scrollEvent:"scroll",submitEvent:"submit",loadEvent:"load",unloadEvent:"unload",readystatechangeEvent:"readystatechange",beforeunloadEvent:"beforeunload",orientationchangeEvent:"orientationchange",contextmenuEvent:"contextmenu",DOMContentLoadedEvent:"DOMContentLoaded",DOMMouseScrollEvent:"DOMMouseScroll",selectEvent:"select",selectendEvent:"selectend",selectstartEvent:"selectstart",mouseClickEvents:{down:"mousedown",up:"mouseup"},mouseclickEvent:"click",mousedblclickEvent:"dblclick",mousedownEvent:"mousedown",mouseupEvent:"mouseup",mousehoverEvent:"hover",mouseHoverEvents:e,mouseenterEvent:"mouseenter",mouseleaveEvent:"mouseleave",mouseinEvent:"mousein",mouseoutEvent:"mouseout",mousemoveEvent:"mousemove",mousewheelEvent:"mousewheel",mouseSwipeEvents:{start:"mousedown",end:"mouseup",move:"mousemove",cancel:"mouseleave"},touchEvents:{start:"touchstart",end:"touchend",move:"touchmove",cancel:"touchcancel"},touchstartEvent:"touchstart",touchmoveEvent:"touchmove",touchcancelEvent:"touchcancel",touchendEvent:"touchend",pointercancelEvent:"pointercancel",pointerdownEvent:"pointerdown",pointerleaveEvent:"pointerleave",pointermoveEvent:"pointermove",pointerupEvent:"pointerup",focusEvents:{in:"focusin",out:"focusout"},focusEvent:"focus",focusinEvent:"focusin",focusoutEvent:"focusout",gesturechangeEvent:"gesturechange",gestureendEvent:"gestureend",gesturestartEvent:"gesturestart",bezierEasings:{linear:"linear",easingSinusoidalIn:"cubic-bezier(0.47,0,0.745,0.715)",easingSinusoidalOut:"cubic-bezier(0.39,0.575,0.565,1)",easingSinusoidalInOut:"cubic-bezier(0.445,0.05,0.55,0.95)",easingQuadraticIn:"cubic-bezier(0.550,0.085,0.680,0.530)",easingQuadraticOut:"cubic-bezier(0.250,0.460,0.450,0.940)",easingQuadraticInOut:"cubic-bezier(0.455,0.030,0.515,0.955)",easingCubicIn:"cubic-bezier(0.55,0.055,0.675,0.19)",easingCubicOut:"cubic-bezier(0.215,0.61,0.355,1)",easingCubicInOut:"cubic-bezier(0.645,0.045,0.355,1)",easingQuarticIn:"cubic-bezier(0.895,0.03,0.685,0.22)",easingQuarticOut:"cubic-bezier(0.165,0.84,0.44,1)",easingQuarticInOut:"cubic-bezier(0.77,0,0.175,1)",easingQuinticIn:"cubic-bezier(0.755,0.05,0.855,0.06)",easingQuinticOut:"cubic-bezier(0.23,1,0.32,1)",easingQuinticInOut:"cubic-bezier(0.86,0,0.07,1)",easingExponentialIn:"cubic-bezier(0.95,0.05,0.795,0.035)",easingExponentialOut:"cubic-bezier(0.19,1,0.22,1)",easingExponentialInOut:"cubic-bezier(1,0,0,1)",easingCircularIn:"cubic-bezier(0.6,0.04,0.98,0.335)",easingCircularOut:"cubic-bezier(0.075,0.82,0.165,1)",easingCircularInOut:"cubic-bezier(0.785,0.135,0.15,0.86)",easingBackIn:"cubic-bezier(0.6,-0.28,0.735,0.045)",easingBackOut:"cubic-bezier(0.175,0.885,0.32,1.275)",easingBackInOut:"cubic-bezier(0.68,-0.55,0.265,1.55)"},animationDuration:"animationDuration",animationDurationLegacy:t,animationDelay:"animationDelay",animationDelayLegacy:n,animationName:"animationName",animationNameLegacy:i,animationEndEvent:"animationend",animationEndEventLegacy:o,transitionDuration:"transitionDuration",transitionDurationLegacy:a,transitionDelay:"transitionDelay",transitionDelayLegacy:r,transitionEndEvent:"transitionend",transitionEndEventLegacy:s,transitionProperty:"transitionProperty",transitionPropertyLegacy:c,isMobile:m,isApple:v,support3DTransform:p,supportPassive:h,supportTransform:f,supportTouch:w,supportAnimation:k,supportTransition:A,addEventListener:"addEventListener",removeEventListener:"removeEventListener",keyboardEventKeys:{Backspace:"Backspace",Tab:"Tab",Enter:"Enter",Shift:"Shift",Control:"Control",Alt:"Alt",Pause:"Pause",CapsLock:"CapsLock",Escape:"Escape",Scape:"Space",ArrowLeft:"ArrowLeft",ArrowUp:"ArrowUp",ArrowRight:"ArrowRight",ArrowDown:"ArrowDown",Insert:"Insert",Delete:"Delete",Meta:"Meta",ContextMenu:"ContextMenu",ScrollLock:"ScrollLock"},keydownEvent:"keydown",keypressEvent:"keypress",keyupEvent:"keyup",keyAlt:"Alt",keyArrowDown:"ArrowDown",keyArrowLeft:"ArrowLeft",keyArrowRight:"ArrowRight",keyArrowUp:"ArrowUp",keyBackspace:"Backspace",keyCapsLock:"CapsLock",keyControl:"Control",keyDelete:"Delete",keyEnter:"Enter",keyEscape:"Escape",keyInsert:"Insert",keyMeta:"Meta",keyPause:"Pause",keyScrollLock:"ScrollLock",keyShift:"Shift",keySpace:"Space",keyTab:"Tab",offsetHeight:"offsetHeight",offsetWidth:"offsetWidth",scrollHeight:"scrollHeight",scrollWidth:"scrollWidth",userAgentData:"userAgentData",addClass:function(e,t){e.classList.add(t)},removeClass:function(e,t){e.classList.remove(t)},hasClass:function(e,t){return e.classList.contains(t)},on:E,off:y,one:b,Data:z,Timer:N,getInstance:(e,t)=>z.get(e,t),emulateAnimationEnd:function(e,t){let n=0;const i=new Event("animationend"),o=S(e),a=O(e);if(o){const r=i=>{i.target===e&&(t.apply(e,[i]),e.removeEventListener("animationend",r),n=1)};e.addEventListener("animationend",r),setTimeout(()=>{n||e.dispatchEvent(i)},o+a+17)}else t.apply(e,[i])},emulateAnimationEndLegacy:function(e,t){let n=0;const i=new Event(o),a=P(e),r=I(e);if(k&&a){const s=i=>{i.target===e&&(t.apply(e,[i]),e.removeEventListener(o,s),n=1)};e.addEventListener(o,s),setTimeout(()=>{n||e.dispatchEvent(i)},a+r+17)}else t.apply(e,[i])},emulateTransitionEnd:function(e,t){let n=0;const i=new Event("transitionend"),o=F(e),a=H(e);if(o){const r=i=>{i.target===e&&(t.apply(e,[i]),e.removeEventListener("transitionend",r),n=1)};e.addEventListener("transitionend",r),setTimeout(()=>{n||e.dispatchEvent(i)},o+a+17)}else t.apply(e,[i])},emulateTransitionEndLegacy:function(e,t){let n=0;const i=new Event(s),o=x(e),a=B(e);if(A&&o){const r=i=>{i.target===e&&(t.apply(e,[i]),e.removeEventListener(s,r),n=1)};e.addEventListener(s,r),setTimeout(()=>{n||e.dispatchEvent(i)},o+a+17)}else t.apply(e,[i])},isElementInScrollRange:function(e){const t=e.getBoundingClientRect(),n=window.innerHeight||document.documentElement.clientHeight;return t.top<=n&&t.bottom>=0},isElementInViewport:function(e){const t=e.getBoundingClientRect();return t.top>=0&&t.left>=0&&t.bottom<=(window.innerHeight||document.documentElement.clientHeight)&&t.right<=(window.innerWidth||document.documentElement.clientWidth)},passiveHandler:!!h&&{passive:!0},getElementAnimationDuration:S,getElementAnimationDurationLegacy:P,getElementAnimationDelay:O,getElementAnimationDelayLegacy:I,getElementTransitionDuration:F,getElementTransitionDurationLegacy:x,getElementTransitionDelay:H,getElementTransitionDelayLegacy:B,isArray:e=>Array.isArray(e),isString:e=>e&&"string"==typeof e,isElement:e=>e&&e instanceof Element,isHTMLElement:L,isNodeList:e=>e instanceof NodeList,isHTMLCollection:e=>e instanceof HTMLCollection,isElementsArray:e=>Array.isArray(e)&&e.every(e=>L(e)),isMedia:e=>"object"==typeof e&&[SVGElement,HTMLImageElement,HTMLVideoElement].some(t=>e instanceof t),isRTL:()=>"rtl"===document.documentElement.dir,queryElement:function(e,t){return D(e,t)},querySelector:D,querySelectorAll:function(e,t){return(t&&L(t)?t:document).querySelectorAll(e)},getElementsByClassName:function(e,t){return(t&&L(t)?t:document).getElementsByClassName(e)},getElementsByTagName:function(e,t){return(t&&L(t)?t:document).getElementsByTagName(e)},normalizeValue:j,normalizeOptions:function(e,t,n,i){const o={...e.dataset},a={},r={};return Q(o).forEach(e=>{const t=i&&e.includes(i)?e.replace(i,"").replace(/[A-Z]/,e=>e.toLowerCase()):e;r[t]=j(o[e])}),Q(n).forEach(e=>{n[e]=j(n[e])}),Q(t).forEach(e=>{a[e]=e in n?n[e]:e in r?r[e]:t[e]}),a},tryWrapper:function(e,t){try{e()}catch(e){throw TypeError(`${t} ${e}`)}},reflow:e=>e.offsetHeight,ArrayFrom:e=>Array.from(e),Float32ArrayFrom:e=>Float32Array.from(Array.from(e)),Float64ArrayFrom:e=>Float64Array.from(Array.from(e)),ObjectAssign:R,ObjectKeys:Q,ObjectValues:e=>Object.values(e),getElementStyle:M,setElementStyle:(e,t)=>R(e.style,t),getAttribute:(e,t)=>e.getAttribute(t),setAttribute:(e,t,n)=>e.setAttribute(t,n),removeAttribute:(e,t)=>e.removeAttribute(t),Version:"0.2.25alpha1"};export{V as default}; |
/*! | ||
* shorter-js v0.2.24 (https://github.com/thednp/shorter-js) | ||
* shorter-js v0.2.25alpha1 (https://github.com/thednp/shorter-js) | ||
* Copyright 2019-2022 © dnp_theme | ||
@@ -881,5 +881,5 @@ * Licensed under MIT (https://github.com/thednp/shorter-js/blob/master/LICENSE) | ||
/** | ||
* Add class to Element.classList | ||
* Add class to `HTMLElement.classList`. | ||
* | ||
* @param {Element} element target | ||
* @param {HTMLElement} element target | ||
* @param {string} classNAME to add | ||
@@ -892,5 +892,5 @@ */ | ||
/** | ||
* Remove class from Element.classList | ||
* Remove class from `HTMLElement.classList`. | ||
* | ||
* @param {Element} element target | ||
* @param {HTMLElement} element target | ||
* @param {string} classNAME to remove | ||
@@ -903,5 +903,5 @@ */ | ||
/** | ||
* Check class in Element.classList | ||
* Check class in `HTMLElement.classList`. | ||
* | ||
* @param {Element} element target | ||
* @param {HTMLElement} element target | ||
* @param {string} classNAME to check | ||
@@ -1013,2 +1013,3 @@ * @return {boolean} | ||
/** @type {Map<string, Map<HTMLElement, SHORTER.Component>>} */ | ||
var componentData = new Map(); | ||
@@ -1024,7 +1025,7 @@ /** | ||
* @param {string} component the component's name or a unique key | ||
* @param {any} instance the component instance | ||
* @param {SHORTER.Component} instance the component instance | ||
*/ | ||
set: function (target, component, instance) { | ||
var element = querySelector(target); | ||
if (!isHTMLElement(element)) { return; } | ||
if (!element || !isHTMLElement(element)) { return; } | ||
@@ -1036,2 +1037,3 @@ if (!componentData.has(component)) { | ||
var instanceMap = componentData.get(component); | ||
// @ts-ignore - not undefined, but defined right above | ||
instanceMap.set(element, instance); | ||
@@ -1043,3 +1045,3 @@ }, | ||
* @param {string} component the component's name or a unique key | ||
* @returns {any?} all the component instances | ||
* @returns {Map<HTMLElement, SHORTER.Component> | null | undefined} all the component instances | ||
*/ | ||
@@ -1057,3 +1059,3 @@ getAllFor: function (component) { | ||
* @param {string} component the component's name or a unique key | ||
* @returns {any?} the instance | ||
* @returns {SHORTER.Component | null | undefined} the instance | ||
*/ | ||
@@ -1064,3 +1066,3 @@ get: function (target, component) { | ||
var allForC = Data.getAllFor(component); | ||
if (allForC && isHTMLElement(element) && allForC.has(element)) { | ||
if (allForC && element && isHTMLElement(element) && allForC.has(element)) { | ||
return allForC.get(element); | ||
@@ -1078,5 +1080,5 @@ } | ||
var element = querySelector(target); | ||
if (!componentData.has(component) || !element) { return; } | ||
var instanceMap = componentData.get(component); | ||
if (!instanceMap || !element) { return; } | ||
var instanceMap = componentData.get(component); | ||
instanceMap.delete(element); | ||
@@ -1092,5 +1094,3 @@ | ||
* An alias for `Data.get()`. | ||
* @param {HTMLElement | string} target target element | ||
* @param {string} component the component's name or a unique key | ||
* @returns {Record<string, any>?} the request result | ||
* @type {SHORTER.getInstance<any>} | ||
*/ | ||
@@ -1710,3 +1710,3 @@ var getInstance = function (target, component) { return Data.get(target, component); }; | ||
var version = "0.2.24"; | ||
var version = "0.2.25alpha1"; | ||
@@ -1713,0 +1713,0 @@ // @ts-ignore |
@@ -1,2 +0,2 @@ | ||
// shorter-js v0.2.24 | dnp_theme © 2022 | MIT-License | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).SHORTER=t()}(this,(function(){"use strict";var e="onmouseleave"in document?["mouseenter","mouseleave"]:["mouseover","mouseout"],t="webkitAnimation"in document.head.style?"webkitAnimationDuration":"animationDuration",n="webkitAnimation"in document.head.style?"webkitAnimationDelay":"animationDelay",i="webkitAnimation"in document.head.style?"webkitAnimationName":"animationName",r="webkitAnimation"in document.head.style?"webkitAnimationEnd":"animationend",o="webkitTransition"in document.head.style?"webkitTransitionDuration":"transitionDuration",a="webkitTransition"in document.head.style?"webkitTransitionDelay":"transitionDelay",s="webkitTransition"in document.head.style?"webkitTransitionEnd":"transitionend",u="webkitTransition"in document.head.style?"webkitTransitionProperty":"transitionProperty",c=/iPhone|iPad|iPod|Android/i,l=navigator.userAgentData?navigator.userAgentData.brands.some((function(e){return c.test(e.brand)})):c.test(navigator.userAgent),m=navigator.userAgentData,d=/(iPhone|iPod|iPad)/,v=m?m.brands.some((function(e){return d.test(e.brand)})):d.test(navigator.userAgent),f="webkitPerspective"in document.head.style||"perspective"in document.head.style;function g(e,t,n,i){var r=i||!1;e.addEventListener(t,n,r)}function p(e,t,n,i){var r=i||!1;e.removeEventListener(t,n,r)}function y(e,t,n,i){g(e,t,(function r(o){o.target===e&&(n.apply(e,[o]),p(e,t,r,i))}),i)}var E=function(){var e=!1;try{var t=Object.defineProperty({},"passive",{get:function(){return e=!0}});y(document,"DOMContentLoaded",(function(){}),t)}catch(e){throw Error("Passive events are not supported")}return e}(),b="webkitTransform"in document.head.style||"transform"in document.head.style,h="ontouchstart"in window||"msMaxTouchPoints"in navigator,w="webkitAnimation"in document.head.style||"animation"in document.head.style,k="webkitTransition"in document.head.style||"transition"in document.head.style;var A=function(e){return"object"==typeof e&&e instanceof HTMLElement};function L(e,t){var n=t&&A(t)?t:document;return"object"==typeof e?e:n.querySelector(e)}var D=new Map,T={set:function(e,t,n,i){var r=L(e);A(r)&&(i&&i.length?(D.has(r)||D.set(r,new Map),D.get(r).set(i,setTimeout(t,n))):D.set(r,setTimeout(t,n)))},get:function(e,t){var n=L(e);if(!A(n))return null;if(t&&t.length){D.has(n)||D.set(n,new Map);var i=D.get(n);if(i.has(t))return i.get(t)}else if(D.has(n))return D.get(n);return null},clear:function(e,t){var n=L(e);if(A(n)&&D.has(n))if(t&&t.length){var i=D.get(n);i&&i.has(t)&&(clearTimeout(i.get(t)),i.delete(t))}else D.has(n)&&(clearTimeout(D.get(n)),D.delete(n))}},N=new Map,C={set:function(e,t,n){var i=L(e);A(i)&&(N.has(t)||N.set(t,new Map),N.get(t).set(i,n))},getAllFor:function(e){return N.has(e)?N.get(e):null},get:function(e,t){var n=L(e),i=C.getAllFor(t);return i&&A(n)&&i.has(n)?i.get(n):null},remove:function(e,t){var n=L(e);if(N.has(t)&&n){var i=N.get(t);i.delete(n),0===i.size&&N.delete(t)}}};function O(e,t){var n=getComputedStyle(e);return t&&t in n?n.getPropertyValue(t):""}function z(e){var t=O(e,"animationName"),n=O(e,"animationDelay"),i=n.includes("ms")?1:1e3,r=t&&"none"!==t?parseFloat(n)*i:0;return Number.isNaN(r)?0:r}function M(e){var t=O(e,"animationName"),n=O(e,"animationDuration"),i=n.includes("ms")?1:1e3,r=t&&"none"!==t?parseFloat(n)*i:0;return Number.isNaN(r)?0:r}function S(e){var t=O(e,i),r=O(e,n),o=r.includes("ms")?1:1e3,a=w&&t&&"none"!==t?parseFloat(r)*o:0;return Number.isNaN(a)?0:a}function I(e){var n=O(e,i),r=O(e,t),o=r.includes("ms")?1:1e3,a=w&&n&&"none"!==n?parseFloat(r)*o:0;return Number.isNaN(a)?0:a}function P(e){var t=O(e,"transitionProperty"),n=O(e,"transitionDelay"),i=n.includes("ms")?1:1e3,r=t&&"none"!==t?parseFloat(n)*i:0;return Number.isNaN(r)?0:r}function H(e){var t=O(e,"transitionProperty"),n=O(e,"transitionDuration"),i=n.includes("ms")?1:1e3,r=t&&"none"!==t?parseFloat(n)*i:0;return Number.isNaN(r)?0:r}function F(e){var t=O(e,u),n=O(e,a),i=n.includes("ms")?1:1e3,r=k&&t&&"none"!==t?parseFloat(n)*i:0;return Number.isNaN(r)?0:r}function B(e){var t=O(e,u),n=O(e,o),i=n.includes("ms")?1:1e3,r=k&&t&&"none"!==t?parseFloat(n)*i:0;return Number.isNaN(r)?0:r}function x(e){return"true"===e||"false"!==e&&(Number.isNaN(+e)?""===e||"null"===e?null:e:+e)}var j=function(e){return Object.keys(e)};var R=function(e,t){return Object.assign(e,t)};return{ariaChecked:"aria-checked",ariaDescribedBy:"aria-describedby",ariaExpanded:"aria-expanded",ariaHidden:"aria-hidden",ariaLabel:"aria-label",ariaLabelledBy:"aria-labelledby",ariaModal:"aria-modal",ariaPressed:"aria-pressed",ariaSelected:"aria-selected",nativeEvents:["click","dblclick","mouseup","mousedown","contextmenu","mousewheel","DOMMouseScroll","mouseover","mouseout","mousemove","selectstart","selectend","keydown","keypress","keyup","orientationchange","touchstart","touchmove","touchend","touchcancel","pointercancel","pointerdown","pointerleave","pointermove","pointerup","gesturestart","gesturechange","gestureend","focus","blur","change","reset","select","submit","focusin","focusout","load","unload","beforeunload","resize","move","DOMContentLoaded","readystatechange","error","abort","scroll"],abortEvent:"abort",blurEvent:"blur",moveEvent:"move",changeEvent:"change",errorEvent:"error",resetEvent:"reset",resizeEvent:"resize",scrollEvent:"scroll",submitEvent:"submit",loadEvent:"load",unloadEvent:"unload",readystatechangeEvent:"readystatechange",beforeunloadEvent:"beforeunload",orientationchangeEvent:"orientationchange",contextmenuEvent:"contextmenu",DOMContentLoadedEvent:"DOMContentLoaded",DOMMouseScrollEvent:"DOMMouseScroll",selectEvent:"select",selectendEvent:"selectend",selectstartEvent:"selectstart",mouseClickEvents:{down:"mousedown",up:"mouseup"},mouseclickEvent:"click",mousedblclickEvent:"dblclick",mousedownEvent:"mousedown",mouseupEvent:"mouseup",mousehoverEvent:"hover",mouseHoverEvents:e,mouseenterEvent:"mouseenter",mouseleaveEvent:"mouseleave",mouseinEvent:"mousein",mouseoutEvent:"mouseout",mousemoveEvent:"mousemove",mousewheelEvent:"mousewheel",mouseSwipeEvents:{start:"mousedown",end:"mouseup",move:"mousemove",cancel:"mouseleave"},touchEvents:{start:"touchstart",end:"touchend",move:"touchmove",cancel:"touchcancel"},touchstartEvent:"touchstart",touchmoveEvent:"touchmove",touchcancelEvent:"touchcancel",touchendEvent:"touchend",pointercancelEvent:"pointercancel",pointerdownEvent:"pointerdown",pointerleaveEvent:"pointerleave",pointermoveEvent:"pointermove",pointerupEvent:"pointerup",focusEvents:{in:"focusin",out:"focusout"},focusEvent:"focus",focusinEvent:"focusin",focusoutEvent:"focusout",gesturechangeEvent:"gesturechange",gestureendEvent:"gestureend",gesturestartEvent:"gesturestart",bezierEasings:{linear:"linear",easingSinusoidalIn:"cubic-bezier(0.47,0,0.745,0.715)",easingSinusoidalOut:"cubic-bezier(0.39,0.575,0.565,1)",easingSinusoidalInOut:"cubic-bezier(0.445,0.05,0.55,0.95)",easingQuadraticIn:"cubic-bezier(0.550,0.085,0.680,0.530)",easingQuadraticOut:"cubic-bezier(0.250,0.460,0.450,0.940)",easingQuadraticInOut:"cubic-bezier(0.455,0.030,0.515,0.955)",easingCubicIn:"cubic-bezier(0.55,0.055,0.675,0.19)",easingCubicOut:"cubic-bezier(0.215,0.61,0.355,1)",easingCubicInOut:"cubic-bezier(0.645,0.045,0.355,1)",easingQuarticIn:"cubic-bezier(0.895,0.03,0.685,0.22)",easingQuarticOut:"cubic-bezier(0.165,0.84,0.44,1)",easingQuarticInOut:"cubic-bezier(0.77,0,0.175,1)",easingQuinticIn:"cubic-bezier(0.755,0.05,0.855,0.06)",easingQuinticOut:"cubic-bezier(0.23,1,0.32,1)",easingQuinticInOut:"cubic-bezier(0.86,0,0.07,1)",easingExponentialIn:"cubic-bezier(0.95,0.05,0.795,0.035)",easingExponentialOut:"cubic-bezier(0.19,1,0.22,1)",easingExponentialInOut:"cubic-bezier(1,0,0,1)",easingCircularIn:"cubic-bezier(0.6,0.04,0.98,0.335)",easingCircularOut:"cubic-bezier(0.075,0.82,0.165,1)",easingCircularInOut:"cubic-bezier(0.785,0.135,0.15,0.86)",easingBackIn:"cubic-bezier(0.6,-0.28,0.735,0.045)",easingBackOut:"cubic-bezier(0.175,0.885,0.32,1.275)",easingBackInOut:"cubic-bezier(0.68,-0.55,0.265,1.55)"},animationDuration:"animationDuration",animationDurationLegacy:t,animationDelay:"animationDelay",animationDelayLegacy:n,animationName:"animationName",animationNameLegacy:i,animationEndEvent:"animationend",animationEndEventLegacy:r,transitionDuration:"transitionDuration",transitionDurationLegacy:o,transitionDelay:"transitionDelay",transitionDelayLegacy:a,transitionEndEvent:"transitionend",transitionEndEventLegacy:s,transitionProperty:"transitionProperty",transitionPropertyLegacy:u,isMobile:l,isApple:v,support3DTransform:f,supportPassive:E,supportTransform:b,supportTouch:h,supportAnimation:w,supportTransition:k,addEventListener:"addEventListener",removeEventListener:"removeEventListener",keyboardEventKeys:{Backspace:"Backspace",Tab:"Tab",Enter:"Enter",Shift:"Shift",Control:"Control",Alt:"Alt",Pause:"Pause",CapsLock:"CapsLock",Escape:"Escape",Scape:"Space",ArrowLeft:"ArrowLeft",ArrowUp:"ArrowUp",ArrowRight:"ArrowRight",ArrowDown:"ArrowDown",Insert:"Insert",Delete:"Delete",Meta:"Meta",ContextMenu:"ContextMenu",ScrollLock:"ScrollLock"},keydownEvent:"keydown",keypressEvent:"keypress",keyupEvent:"keyup",keyAlt:"Alt",keyArrowDown:"ArrowDown",keyArrowLeft:"ArrowLeft",keyArrowRight:"ArrowRight",keyArrowUp:"ArrowUp",keyBackspace:"Backspace",keyCapsLock:"CapsLock",keyControl:"Control",keyDelete:"Delete",keyEnter:"Enter",keyEscape:"Escape",keyInsert:"Insert",keyMeta:"Meta",keyPause:"Pause",keyScrollLock:"ScrollLock",keyShift:"Shift",keySpace:"Space",keyTab:"Tab",offsetHeight:"offsetHeight",offsetWidth:"offsetWidth",scrollHeight:"scrollHeight",scrollWidth:"scrollWidth",userAgentData:"userAgentData",addClass:function(e,t){e.classList.add(t)},removeClass:function(e,t){e.classList.remove(t)},hasClass:function(e,t){return e.classList.contains(t)},on:g,off:p,one:y,Data:C,Timer:T,getInstance:function(e,t){return C.get(e,t)},emulateAnimationEnd:function(e,t){var n=0,i=new Event("animationend"),r=M(e),o=z(e);if(r){var a=function(i){i.target===e&&(t.apply(e,[i]),e.removeEventListener("animationend",a),n=1)};e.addEventListener("animationend",a),setTimeout((function(){n||e.dispatchEvent(i)}),r+o+17)}else t.apply(e,[i])},emulateAnimationEndLegacy:function(e,t){var n=0,i=new Event(r),o=I(e),a=S(e);if(w&&o){var s=function(i){i.target===e&&(t.apply(e,[i]),e.removeEventListener(r,s),n=1)};e.addEventListener(r,s),setTimeout((function(){n||e.dispatchEvent(i)}),o+a+17)}else t.apply(e,[i])},emulateTransitionEnd:function(e,t){var n=0,i=new Event("transitionend"),r=H(e),o=P(e);if(r){var a=function(i){i.target===e&&(t.apply(e,[i]),e.removeEventListener("transitionend",a),n=1)};e.addEventListener("transitionend",a),setTimeout((function(){n||e.dispatchEvent(i)}),r+o+17)}else t.apply(e,[i])},emulateTransitionEndLegacy:function(e,t){var n=0,i=new Event(s),r=B(e),o=F(e);if(k&&r){var a=function(i){i.target===e&&(t.apply(e,[i]),e.removeEventListener(s,a),n=1)};e.addEventListener(s,a),setTimeout((function(){n||e.dispatchEvent(i)}),r+o+17)}else t.apply(e,[i])},isElementInScrollRange:function(e){var t=e.getBoundingClientRect(),n=window.innerHeight||document.documentElement.clientHeight;return t.top<=n&&t.bottom>=0},isElementInViewport:function(e){var t=e.getBoundingClientRect();return t.top>=0&&t.left>=0&&t.bottom<=(window.innerHeight||document.documentElement.clientHeight)&&t.right<=(window.innerWidth||document.documentElement.clientWidth)},passiveHandler:!!E&&{passive:!0},getElementAnimationDuration:M,getElementAnimationDurationLegacy:I,getElementAnimationDelay:z,getElementAnimationDelayLegacy:S,getElementTransitionDuration:H,getElementTransitionDurationLegacy:B,getElementTransitionDelay:P,getElementTransitionDelayLegacy:F,isArray:function(e){return Array.isArray(e)},isString:function(e){return e&&"string"==typeof e},isElement:function(e){return e&&e instanceof Element},isHTMLElement:A,isNodeList:function(e){return e instanceof NodeList},isHTMLCollection:function(e){return e instanceof HTMLCollection},isElementsArray:function(e){return Array.isArray(e)&&e.every((function(e){return A(e)}))},isMedia:function(e){return"object"==typeof e&&[SVGElement,HTMLImageElement,HTMLVideoElement].some((function(t){return e instanceof t}))},isRTL:function(){return"rtl"===document.documentElement.dir},queryElement:function(e,t){return L(e,t)},querySelector:L,querySelectorAll:function(e,t){return(t&&A(t)?t:document).querySelectorAll(e)},getElementsByClassName:function(e,t){return(t&&A(t)?t:document).getElementsByClassName(e)},getElementsByTagName:function(e,t){return(t&&A(t)?t:document).getElementsByTagName(e)},normalizeValue:x,normalizeOptions:function(e,t,n,i){var r=Object.assign({},e.dataset),o={},a={};return j(r).forEach((function(e){var t=i&&e.includes(i)?e.replace(i,"").replace(/[A-Z]/,(function(e){return e.toLowerCase()})):e;a[t]=x(r[e])})),j(n).forEach((function(e){n[e]=x(n[e])})),j(t).forEach((function(e){o[e]=e in n?n[e]:e in a?a[e]:t[e]})),o},tryWrapper:function(e,t){try{e()}catch(e){throw TypeError(t+" "+e)}},reflow:function(e){return e.offsetHeight},ArrayFrom:function(e){return Array.from(e)},Float32ArrayFrom:function(e){return Float32Array.from(Array.from(e))},Float64ArrayFrom:function(e){return Float64Array.from(Array.from(e))},ObjectAssign:R,ObjectKeys:j,ObjectValues:function(e){return Object.values(e)},getElementStyle:O,setElementStyle:function(e,t){return R(e.style,t)},getAttribute:function(e,t){return e.getAttribute(t)},setAttribute:function(e,t,n){return e.setAttribute(t,n)},removeAttribute:function(e,t){return e.removeAttribute(t)},Version:"0.2.24"}})); | ||
// shorter-js v0.2.25alpha1 | dnp_theme © 2022 | MIT-License | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).SHORTER=t()}(this,(function(){"use strict";var e="onmouseleave"in document?["mouseenter","mouseleave"]:["mouseover","mouseout"],t="webkitAnimation"in document.head.style?"webkitAnimationDuration":"animationDuration",n="webkitAnimation"in document.head.style?"webkitAnimationDelay":"animationDelay",i="webkitAnimation"in document.head.style?"webkitAnimationName":"animationName",r="webkitAnimation"in document.head.style?"webkitAnimationEnd":"animationend",o="webkitTransition"in document.head.style?"webkitTransitionDuration":"transitionDuration",a="webkitTransition"in document.head.style?"webkitTransitionDelay":"transitionDelay",u="webkitTransition"in document.head.style?"webkitTransitionEnd":"transitionend",s="webkitTransition"in document.head.style?"webkitTransitionProperty":"transitionProperty",c=/iPhone|iPad|iPod|Android/i,l=navigator.userAgentData?navigator.userAgentData.brands.some((function(e){return c.test(e.brand)})):c.test(navigator.userAgent),m=navigator.userAgentData,d=/(iPhone|iPod|iPad)/,v=m?m.brands.some((function(e){return d.test(e.brand)})):d.test(navigator.userAgent),f="webkitPerspective"in document.head.style||"perspective"in document.head.style;function g(e,t,n,i){var r=i||!1;e.addEventListener(t,n,r)}function p(e,t,n,i){var r=i||!1;e.removeEventListener(t,n,r)}function y(e,t,n,i){g(e,t,(function r(o){o.target===e&&(n.apply(e,[o]),p(e,t,r,i))}),i)}var E=function(){var e=!1;try{var t=Object.defineProperty({},"passive",{get:function(){return e=!0}});y(document,"DOMContentLoaded",(function(){}),t)}catch(e){throw Error("Passive events are not supported")}return e}(),b="webkitTransform"in document.head.style||"transform"in document.head.style,h="ontouchstart"in window||"msMaxTouchPoints"in navigator,w="webkitAnimation"in document.head.style||"animation"in document.head.style,k="webkitTransition"in document.head.style||"transition"in document.head.style;var A=function(e){return"object"==typeof e&&e instanceof HTMLElement};function L(e,t){var n=t&&A(t)?t:document;return"object"==typeof e?e:n.querySelector(e)}var D=new Map,T={set:function(e,t,n,i){var r=L(e);A(r)&&(i&&i.length?(D.has(r)||D.set(r,new Map),D.get(r).set(i,setTimeout(t,n))):D.set(r,setTimeout(t,n)))},get:function(e,t){var n=L(e);if(!A(n))return null;if(t&&t.length){D.has(n)||D.set(n,new Map);var i=D.get(n);if(i.has(t))return i.get(t)}else if(D.has(n))return D.get(n);return null},clear:function(e,t){var n=L(e);if(A(n)&&D.has(n))if(t&&t.length){var i=D.get(n);i&&i.has(t)&&(clearTimeout(i.get(t)),i.delete(t))}else D.has(n)&&(clearTimeout(D.get(n)),D.delete(n))}},N=new Map,C={set:function(e,t,n){var i=L(e);i&&A(i)&&(N.has(t)||N.set(t,new Map),N.get(t).set(i,n))},getAllFor:function(e){return N.has(e)?N.get(e):null},get:function(e,t){var n=L(e),i=C.getAllFor(t);return i&&n&&A(n)&&i.has(n)?i.get(n):null},remove:function(e,t){var n=L(e),i=N.get(t);i&&n&&(i.delete(n),0===i.size&&N.delete(t))}};function O(e,t){var n=getComputedStyle(e);return t&&t in n?n.getPropertyValue(t):""}function z(e){var t=O(e,"animationName"),n=O(e,"animationDelay"),i=n.includes("ms")?1:1e3,r=t&&"none"!==t?parseFloat(n)*i:0;return Number.isNaN(r)?0:r}function M(e){var t=O(e,"animationName"),n=O(e,"animationDuration"),i=n.includes("ms")?1:1e3,r=t&&"none"!==t?parseFloat(n)*i:0;return Number.isNaN(r)?0:r}function S(e){var t=O(e,i),r=O(e,n),o=r.includes("ms")?1:1e3,a=w&&t&&"none"!==t?parseFloat(r)*o:0;return Number.isNaN(a)?0:a}function I(e){var n=O(e,i),r=O(e,t),o=r.includes("ms")?1:1e3,a=w&&n&&"none"!==n?parseFloat(r)*o:0;return Number.isNaN(a)?0:a}function P(e){var t=O(e,"transitionProperty"),n=O(e,"transitionDelay"),i=n.includes("ms")?1:1e3,r=t&&"none"!==t?parseFloat(n)*i:0;return Number.isNaN(r)?0:r}function H(e){var t=O(e,"transitionProperty"),n=O(e,"transitionDuration"),i=n.includes("ms")?1:1e3,r=t&&"none"!==t?parseFloat(n)*i:0;return Number.isNaN(r)?0:r}function F(e){var t=O(e,s),n=O(e,a),i=n.includes("ms")?1:1e3,r=k&&t&&"none"!==t?parseFloat(n)*i:0;return Number.isNaN(r)?0:r}function B(e){var t=O(e,s),n=O(e,o),i=n.includes("ms")?1:1e3,r=k&&t&&"none"!==t?parseFloat(n)*i:0;return Number.isNaN(r)?0:r}function x(e){return"true"===e||"false"!==e&&(Number.isNaN(+e)?""===e||"null"===e?null:e:+e)}var j=function(e){return Object.keys(e)};var R=function(e,t){return Object.assign(e,t)};return{ariaChecked:"aria-checked",ariaDescribedBy:"aria-describedby",ariaExpanded:"aria-expanded",ariaHidden:"aria-hidden",ariaLabel:"aria-label",ariaLabelledBy:"aria-labelledby",ariaModal:"aria-modal",ariaPressed:"aria-pressed",ariaSelected:"aria-selected",nativeEvents:["click","dblclick","mouseup","mousedown","contextmenu","mousewheel","DOMMouseScroll","mouseover","mouseout","mousemove","selectstart","selectend","keydown","keypress","keyup","orientationchange","touchstart","touchmove","touchend","touchcancel","pointercancel","pointerdown","pointerleave","pointermove","pointerup","gesturestart","gesturechange","gestureend","focus","blur","change","reset","select","submit","focusin","focusout","load","unload","beforeunload","resize","move","DOMContentLoaded","readystatechange","error","abort","scroll"],abortEvent:"abort",blurEvent:"blur",moveEvent:"move",changeEvent:"change",errorEvent:"error",resetEvent:"reset",resizeEvent:"resize",scrollEvent:"scroll",submitEvent:"submit",loadEvent:"load",unloadEvent:"unload",readystatechangeEvent:"readystatechange",beforeunloadEvent:"beforeunload",orientationchangeEvent:"orientationchange",contextmenuEvent:"contextmenu",DOMContentLoadedEvent:"DOMContentLoaded",DOMMouseScrollEvent:"DOMMouseScroll",selectEvent:"select",selectendEvent:"selectend",selectstartEvent:"selectstart",mouseClickEvents:{down:"mousedown",up:"mouseup"},mouseclickEvent:"click",mousedblclickEvent:"dblclick",mousedownEvent:"mousedown",mouseupEvent:"mouseup",mousehoverEvent:"hover",mouseHoverEvents:e,mouseenterEvent:"mouseenter",mouseleaveEvent:"mouseleave",mouseinEvent:"mousein",mouseoutEvent:"mouseout",mousemoveEvent:"mousemove",mousewheelEvent:"mousewheel",mouseSwipeEvents:{start:"mousedown",end:"mouseup",move:"mousemove",cancel:"mouseleave"},touchEvents:{start:"touchstart",end:"touchend",move:"touchmove",cancel:"touchcancel"},touchstartEvent:"touchstart",touchmoveEvent:"touchmove",touchcancelEvent:"touchcancel",touchendEvent:"touchend",pointercancelEvent:"pointercancel",pointerdownEvent:"pointerdown",pointerleaveEvent:"pointerleave",pointermoveEvent:"pointermove",pointerupEvent:"pointerup",focusEvents:{in:"focusin",out:"focusout"},focusEvent:"focus",focusinEvent:"focusin",focusoutEvent:"focusout",gesturechangeEvent:"gesturechange",gestureendEvent:"gestureend",gesturestartEvent:"gesturestart",bezierEasings:{linear:"linear",easingSinusoidalIn:"cubic-bezier(0.47,0,0.745,0.715)",easingSinusoidalOut:"cubic-bezier(0.39,0.575,0.565,1)",easingSinusoidalInOut:"cubic-bezier(0.445,0.05,0.55,0.95)",easingQuadraticIn:"cubic-bezier(0.550,0.085,0.680,0.530)",easingQuadraticOut:"cubic-bezier(0.250,0.460,0.450,0.940)",easingQuadraticInOut:"cubic-bezier(0.455,0.030,0.515,0.955)",easingCubicIn:"cubic-bezier(0.55,0.055,0.675,0.19)",easingCubicOut:"cubic-bezier(0.215,0.61,0.355,1)",easingCubicInOut:"cubic-bezier(0.645,0.045,0.355,1)",easingQuarticIn:"cubic-bezier(0.895,0.03,0.685,0.22)",easingQuarticOut:"cubic-bezier(0.165,0.84,0.44,1)",easingQuarticInOut:"cubic-bezier(0.77,0,0.175,1)",easingQuinticIn:"cubic-bezier(0.755,0.05,0.855,0.06)",easingQuinticOut:"cubic-bezier(0.23,1,0.32,1)",easingQuinticInOut:"cubic-bezier(0.86,0,0.07,1)",easingExponentialIn:"cubic-bezier(0.95,0.05,0.795,0.035)",easingExponentialOut:"cubic-bezier(0.19,1,0.22,1)",easingExponentialInOut:"cubic-bezier(1,0,0,1)",easingCircularIn:"cubic-bezier(0.6,0.04,0.98,0.335)",easingCircularOut:"cubic-bezier(0.075,0.82,0.165,1)",easingCircularInOut:"cubic-bezier(0.785,0.135,0.15,0.86)",easingBackIn:"cubic-bezier(0.6,-0.28,0.735,0.045)",easingBackOut:"cubic-bezier(0.175,0.885,0.32,1.275)",easingBackInOut:"cubic-bezier(0.68,-0.55,0.265,1.55)"},animationDuration:"animationDuration",animationDurationLegacy:t,animationDelay:"animationDelay",animationDelayLegacy:n,animationName:"animationName",animationNameLegacy:i,animationEndEvent:"animationend",animationEndEventLegacy:r,transitionDuration:"transitionDuration",transitionDurationLegacy:o,transitionDelay:"transitionDelay",transitionDelayLegacy:a,transitionEndEvent:"transitionend",transitionEndEventLegacy:u,transitionProperty:"transitionProperty",transitionPropertyLegacy:s,isMobile:l,isApple:v,support3DTransform:f,supportPassive:E,supportTransform:b,supportTouch:h,supportAnimation:w,supportTransition:k,addEventListener:"addEventListener",removeEventListener:"removeEventListener",keyboardEventKeys:{Backspace:"Backspace",Tab:"Tab",Enter:"Enter",Shift:"Shift",Control:"Control",Alt:"Alt",Pause:"Pause",CapsLock:"CapsLock",Escape:"Escape",Scape:"Space",ArrowLeft:"ArrowLeft",ArrowUp:"ArrowUp",ArrowRight:"ArrowRight",ArrowDown:"ArrowDown",Insert:"Insert",Delete:"Delete",Meta:"Meta",ContextMenu:"ContextMenu",ScrollLock:"ScrollLock"},keydownEvent:"keydown",keypressEvent:"keypress",keyupEvent:"keyup",keyAlt:"Alt",keyArrowDown:"ArrowDown",keyArrowLeft:"ArrowLeft",keyArrowRight:"ArrowRight",keyArrowUp:"ArrowUp",keyBackspace:"Backspace",keyCapsLock:"CapsLock",keyControl:"Control",keyDelete:"Delete",keyEnter:"Enter",keyEscape:"Escape",keyInsert:"Insert",keyMeta:"Meta",keyPause:"Pause",keyScrollLock:"ScrollLock",keyShift:"Shift",keySpace:"Space",keyTab:"Tab",offsetHeight:"offsetHeight",offsetWidth:"offsetWidth",scrollHeight:"scrollHeight",scrollWidth:"scrollWidth",userAgentData:"userAgentData",addClass:function(e,t){e.classList.add(t)},removeClass:function(e,t){e.classList.remove(t)},hasClass:function(e,t){return e.classList.contains(t)},on:g,off:p,one:y,Data:C,Timer:T,getInstance:function(e,t){return C.get(e,t)},emulateAnimationEnd:function(e,t){var n=0,i=new Event("animationend"),r=M(e),o=z(e);if(r){var a=function(i){i.target===e&&(t.apply(e,[i]),e.removeEventListener("animationend",a),n=1)};e.addEventListener("animationend",a),setTimeout((function(){n||e.dispatchEvent(i)}),r+o+17)}else t.apply(e,[i])},emulateAnimationEndLegacy:function(e,t){var n=0,i=new Event(r),o=I(e),a=S(e);if(w&&o){var u=function(i){i.target===e&&(t.apply(e,[i]),e.removeEventListener(r,u),n=1)};e.addEventListener(r,u),setTimeout((function(){n||e.dispatchEvent(i)}),o+a+17)}else t.apply(e,[i])},emulateTransitionEnd:function(e,t){var n=0,i=new Event("transitionend"),r=H(e),o=P(e);if(r){var a=function(i){i.target===e&&(t.apply(e,[i]),e.removeEventListener("transitionend",a),n=1)};e.addEventListener("transitionend",a),setTimeout((function(){n||e.dispatchEvent(i)}),r+o+17)}else t.apply(e,[i])},emulateTransitionEndLegacy:function(e,t){var n=0,i=new Event(u),r=B(e),o=F(e);if(k&&r){var a=function(i){i.target===e&&(t.apply(e,[i]),e.removeEventListener(u,a),n=1)};e.addEventListener(u,a),setTimeout((function(){n||e.dispatchEvent(i)}),r+o+17)}else t.apply(e,[i])},isElementInScrollRange:function(e){var t=e.getBoundingClientRect(),n=window.innerHeight||document.documentElement.clientHeight;return t.top<=n&&t.bottom>=0},isElementInViewport:function(e){var t=e.getBoundingClientRect();return t.top>=0&&t.left>=0&&t.bottom<=(window.innerHeight||document.documentElement.clientHeight)&&t.right<=(window.innerWidth||document.documentElement.clientWidth)},passiveHandler:!!E&&{passive:!0},getElementAnimationDuration:M,getElementAnimationDurationLegacy:I,getElementAnimationDelay:z,getElementAnimationDelayLegacy:S,getElementTransitionDuration:H,getElementTransitionDurationLegacy:B,getElementTransitionDelay:P,getElementTransitionDelayLegacy:F,isArray:function(e){return Array.isArray(e)},isString:function(e){return e&&"string"==typeof e},isElement:function(e){return e&&e instanceof Element},isHTMLElement:A,isNodeList:function(e){return e instanceof NodeList},isHTMLCollection:function(e){return e instanceof HTMLCollection},isElementsArray:function(e){return Array.isArray(e)&&e.every((function(e){return A(e)}))},isMedia:function(e){return"object"==typeof e&&[SVGElement,HTMLImageElement,HTMLVideoElement].some((function(t){return e instanceof t}))},isRTL:function(){return"rtl"===document.documentElement.dir},queryElement:function(e,t){return L(e,t)},querySelector:L,querySelectorAll:function(e,t){return(t&&A(t)?t:document).querySelectorAll(e)},getElementsByClassName:function(e,t){return(t&&A(t)?t:document).getElementsByClassName(e)},getElementsByTagName:function(e,t){return(t&&A(t)?t:document).getElementsByTagName(e)},normalizeValue:x,normalizeOptions:function(e,t,n,i){var r=Object.assign({},e.dataset),o={},a={};return j(r).forEach((function(e){var t=i&&e.includes(i)?e.replace(i,"").replace(/[A-Z]/,(function(e){return e.toLowerCase()})):e;a[t]=x(r[e])})),j(n).forEach((function(e){n[e]=x(n[e])})),j(t).forEach((function(e){o[e]=e in n?n[e]:e in a?a[e]:t[e]})),o},tryWrapper:function(e,t){try{e()}catch(e){throw TypeError(t+" "+e)}},reflow:function(e){return e.offsetHeight},ArrayFrom:function(e){return Array.from(e)},Float32ArrayFrom:function(e){return Float32Array.from(Array.from(e))},Float64ArrayFrom:function(e){return Float64Array.from(Array.from(e))},ObjectAssign:R,ObjectKeys:j,ObjectValues:function(e){return Object.values(e)},getElementStyle:O,setElementStyle:function(e,t){return R(e.style,t)},getAttribute:function(e,t){return e.getAttribute(t)},setAttribute:function(e,t,n){return e.setAttribute(t,n)},removeAttribute:function(e,t){return e.removeAttribute(t)},Version:"0.2.25alpha1"}})); |
{ | ||
"name": "shorter-js", | ||
"version": "0.2.24", | ||
"version": "0.2.25alpha1", | ||
"description": "A small ES6+ library with various JavaScript tools useful for creating light libraries.", | ||
@@ -5,0 +5,0 @@ "main": "dist/shorter-js.min.js", |
/** | ||
* Add class to Element.classList | ||
* Add class to `HTMLElement.classList`. | ||
* | ||
* @param {Element} element target | ||
* @param {HTMLElement} element target | ||
* @param {string} classNAME to add | ||
@@ -6,0 +6,0 @@ */ |
/** | ||
* Check class in Element.classList | ||
* Check class in `HTMLElement.classList`. | ||
* | ||
* @param {Element} element target | ||
* @param {HTMLElement} element target | ||
* @param {string} classNAME to check | ||
@@ -6,0 +6,0 @@ * @return {boolean} |
/** | ||
* Remove class from Element.classList | ||
* Remove class from `HTMLElement.classList`. | ||
* | ||
* @param {Element} element target | ||
* @param {HTMLElement} element target | ||
* @param {string} classNAME to remove | ||
@@ -6,0 +6,0 @@ */ |
import querySelector from './querySelector'; | ||
import isHTMLElement from './isHTMLElement'; | ||
/** @type {Map<string, Map<HTMLElement, SHORTER.Component>>} */ | ||
const componentData = new Map(); | ||
@@ -14,7 +15,7 @@ /** | ||
* @param {string} component the component's name or a unique key | ||
* @param {any} instance the component instance | ||
* @param {SHORTER.Component} instance the component instance | ||
*/ | ||
set: (target, component, instance) => { | ||
const element = querySelector(target); | ||
if (!isHTMLElement(element)) return; | ||
if (!element || !isHTMLElement(element)) return; | ||
@@ -26,2 +27,3 @@ if (!componentData.has(component)) { | ||
const instanceMap = componentData.get(component); | ||
// @ts-ignore - not undefined, but defined right above | ||
instanceMap.set(element, instance); | ||
@@ -33,3 +35,3 @@ }, | ||
* @param {string} component the component's name or a unique key | ||
* @returns {any?} all the component instances | ||
* @returns {Map<HTMLElement, SHORTER.Component> | null | undefined} all the component instances | ||
*/ | ||
@@ -47,3 +49,3 @@ getAllFor: (component) => { | ||
* @param {string} component the component's name or a unique key | ||
* @returns {any?} the instance | ||
* @returns {SHORTER.Component | null | undefined} the instance | ||
*/ | ||
@@ -54,3 +56,3 @@ get: (target, component) => { | ||
const allForC = Data.getAllFor(component); | ||
if (allForC && isHTMLElement(element) && allForC.has(element)) { | ||
if (allForC && element && isHTMLElement(element) && allForC.has(element)) { | ||
return allForC.get(element); | ||
@@ -68,5 +70,5 @@ } | ||
const element = querySelector(target); | ||
if (!componentData.has(component) || !element) return; | ||
const instanceMap = componentData.get(component); | ||
if (!instanceMap || !element) return; | ||
const instanceMap = componentData.get(component); | ||
instanceMap.delete(element); | ||
@@ -82,5 +84,3 @@ | ||
* An alias for `Data.get()`. | ||
* @param {HTMLElement | string} target target element | ||
* @param {string} component the component's name or a unique key | ||
* @returns {Record<string, any>?} the request result | ||
* @type {SHORTER.getInstance<any>} | ||
*/ | ||
@@ -87,0 +87,0 @@ export const getInstance = (target, component) => Data.get(target, component); |
@@ -124,3 +124,3 @@ export as namespace SHORTER; | ||
export { default as one } from "shorter-js/src/event/one"; | ||
export { default as Data, getInstance } from "shorter-js/src/misc/data"; | ||
export { default as Data } from "shorter-js/src/misc/data"; | ||
export { default as Timer } from "shorter-js/src/misc/timer"; | ||
@@ -172,1 +172,6 @@ export { default as emulateAnimationEnd } from "shorter-js/src/misc/emulateAnimationEnd"; | ||
export { default as Version } from "shorter-js/src/misc/version"; | ||
export { | ||
Component, | ||
getInstance | ||
} from './module/types' |
@@ -961,27 +961,27 @@ declare module "shorter-js/src/strings/ariaChecked" { | ||
/** | ||
* Add class to Element.classList | ||
* Add class to `HTMLElement.classList`. | ||
* | ||
* @param {Element} element target | ||
* @param {HTMLElement} element target | ||
* @param {string} classNAME to add | ||
*/ | ||
export default function addClass(element: Element, classNAME: string): void; | ||
export default function addClass(element: HTMLElement, classNAME: string): void; | ||
} | ||
declare module "shorter-js/src/class/removeClass" { | ||
/** | ||
* Remove class from Element.classList | ||
* Remove class from `HTMLElement.classList`. | ||
* | ||
* @param {Element} element target | ||
* @param {HTMLElement} element target | ||
* @param {string} classNAME to remove | ||
*/ | ||
export default function removeClass(element: Element, classNAME: string): void; | ||
export default function removeClass(element: HTMLElement, classNAME: string): void; | ||
} | ||
declare module "shorter-js/src/class/hasClass" { | ||
/** | ||
* Check class in Element.classList | ||
* Check class in `HTMLElement.classList`. | ||
* | ||
* @param {Element} element target | ||
* @param {HTMLElement} element target | ||
* @param {string} classNAME to check | ||
* @return {boolean} | ||
*/ | ||
export default function hasClass(element: Element, classNAME: string): boolean; | ||
export default function hasClass(element: HTMLElement, classNAME: string): boolean; | ||
} | ||
@@ -1010,3 +1010,7 @@ declare module "shorter-js/src/misc/isHTMLElement" { | ||
declare module "shorter-js/src/misc/data" { | ||
export function getInstance(target: HTMLElement | string, component: string): Record<string, any> | null; | ||
/** | ||
* An alias for `Data.get()`. | ||
* @type {SHORTER.getInstance<any>} | ||
*/ | ||
export const getInstance: SHORTER.getInstance<any>; | ||
export default Data; | ||
@@ -1013,0 +1017,0 @@ namespace Data { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
292842
181
7439
1