Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Socket
Sign inDemoInstall

shorter-js

Package Overview
Dependencies
Maintainers
1
Versions
82
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

shorter-js - npm Package Compare versions

Comparing version 0.2.13 to 0.2.14

src/boolean/isApple.js

141

dist/shorter-js.esm.js
/*!
* shorter-js v0.2.13 (https://github.com/thednp/shorter-js)
* shorter-js v0.2.14 (https://github.com/thednp/shorter-js)
* Copyright 2019-2021 © dnp_theme

@@ -204,3 +204,13 @@ * Licensed under MIT (https://github.com/thednp/shorter-js/blob/master/LICENSE)

const appleBrands = /(iPhone|iPod|iPad)/;
/**
* A global namespace for Apple browsers.
*/
// @ts-ignore
const { userAgentData } = navigator;
const isApple = !userAgentData ? appleBrands.test(navigator.userAgent)
: userAgentData.brands.some((x) => appleBrands.test(x.brand));
/**
* A global namespace for CSS3 3D transform support.

@@ -339,2 +349,103 @@ * @type {boolean}

/**
* Checks if an element is an `Element`.
*
* @param {any} element the target element
* @returns {boolean} the query result
*/
function isElement(element) {
return element instanceof Element;
}
/**
* Utility to check if target is typeof Element
* or find one that matches a selector.
*
* @param {Element | string} selector the input selector or target element
* @param {Element=} parent optional Element to look into
* @return {Element?} the Element or `querySelector` result
*/
function queryElement(selector, parent) {
const lookUp = parent && isElement(parent) ? parent : document;
// @ts-ignore
return isElement(selector) ? selector : lookUp.querySelector(selector);
}
const componentData = new Map();
/**
* An interface for web components background data.
* @see https://github.com/thednp/bootstrap.native/blob/master/src/components/base-component.js
*/
const Data = {
/**
* Sets web components data.
* @param {Element | string} element target element
* @param {string} component the component's name or a unique key
* @param {Record<string, any>} instance the component instance
*/
set: (element, component, instance) => {
const ELEMENT = queryElement(element);
if (!isElement(ELEMENT)) return;
if (!componentData.has(component)) {
componentData.set(component, new Map());
}
const instanceMap = componentData.get(component);
instanceMap.set(ELEMENT, instance);
},
/**
* Returns all instances for specified component.
* @param {string} component the component's name or a unique key
* @returns {any?} all the component instances
*/
getAllFor: (component) => {
if (componentData.has(component)) {
return componentData.get(component);
}
return null;
},
/**
* Returns the instance associated with the target.
* @param {Element | string} element target element
* @param {string} component the component's name or a unique key
* @returns {any?} the instance
*/
get: (element, component) => {
const ELEMENT = queryElement(element);
const allForC = Data.getAllFor(component);
if (allForC && isElement(ELEMENT) && allForC.has(ELEMENT)) {
return allForC.get(ELEMENT);
}
return null;
},
/**
* Removes web components data.
* @param {Element} element target element
* @param {string} component the component's name or a unique key
*/
remove: (element, component) => {
if (!componentData.has(component)) return;
const instanceMap = componentData.get(component);
instanceMap.delete(element);
if (instanceMap.size === 0) {
componentData.delete(component);
}
},
};
/**
* An alias for `Data.get()`.
* @param {Element} element target element
* @param {string} component the component's name or a unique key
* @returns {any} the request result
*/
const getInstance = (element, component) => Data.get(element, component);
/**
* Utility to get the computed animationDelay

@@ -522,12 +633,2 @@ * from Element in miliseconds.

/**
* Checks if an element is an `Element`.
*
* @param {any} element the target element
* @returns {boolean} the query result
*/
function isElement(element) {
return element instanceof Element;
}
/**
* Checks if an element is an `<svg>`, `<img>` or `<video>`.

@@ -557,15 +658,2 @@ * *Tooltip* / *Popover* works different with media elements.

/**
* Utility to check if target is typeof Element
* or find one that matches a selector.
*
* @param {Element | string} selector the input selector or target element
* @param {Element | null} parent optional Element to look into
* @return {Element | null} the Element or result of the querySelector
*/
function queryElement(selector, parent) {
const lookUp = parent && parent instanceof Element ? parent : document;
return selector instanceof Element ? selector : lookUp.querySelector(selector);
}
/**
* The raw value or a given component option.

@@ -669,3 +757,3 @@ *

var version = "0.2.13";
var version = "0.2.14";

@@ -707,2 +795,3 @@ // @ts-ignore

isMobile,
isApple,
support3DTransform,

@@ -722,2 +811,4 @@ supportPassive,

one,
Data,
getInstance,
emulateAnimationEnd,

@@ -724,0 +815,0 @@ emulateTransitionEnd,

4

dist/shorter-js.esm.min.js

@@ -1,2 +0,2 @@

// shorter-js v0.2.13 | dnp_theme © 2021 | MIT-License
const e="onmouseleave"in document?["mouseenter","mouseleave"]:["mouseover","mouseout"],n="webkitAnimation"in document.head.style?"webkitAnimationDuration":"animationDuration",t="webkitAnimation"in document.head.style?"webkitAnimationDelay":"animationDelay",i="webkitAnimation"in document.head.style?"webkitAnimationEnd":"animationend",a="webkitAnimation"in document.head.style?"webkitAnimationName":"animationName",o="webkitTransition"in document.head.style?"webkitTransitionDuration":"transitionDuration",r="webkitTransition"in document.head.style?"webkitTransitionProperty":"transitionProperty",s="webkitTransition"in document.head.style?"webkitTransitionDelay":"transitionDelay",u="webkitTransition"in document.head.style?"webkitTransitionEnd":"transitionend",c=/iPhone|iPad|iPod|Android/i;let d=!1;d=navigator.userAgentData?navigator.userAgentData.brands.some(e=>c.test(e.brand)):c.test(navigator.userAgent);const l=d,m="webkitPerspective"in document.head.style||"perspective"in document.head.style,b=(()=>{let e=!1;try{const n=Object.defineProperty({},"passive",{get:()=>(e=!0,e)});document.addEventListener("DOMContentLoaded",(function e(){document.removeEventListener("DOMContentLoaded",e,n)}),n)}catch(e){throw Error("Passive events are not supported")}return e})(),p="webkitTransform"in document.head.style||"transform"in document.head.style,E="ontouchstart"in window||"msMaxTouchPoints"in navigator,g="webkitAnimation"in document.head.style||"animation"in document.head.style,v="webkitTransition"in document.head.style||"transition"in document.head.style;function f(e,n,t,i){const a=i||!1;e.addEventListener(n,t,a)}function y(e,n,t,i){const a=i||!1;e.removeEventListener(n,t,a)}function h(e){const n=getComputedStyle(e),i=n[a],o=n[t],r=o.includes("ms")?1:1e3,s=g&&i&&"none"!==i?parseFloat(o)*r:0;return Number.isNaN(s)?0:s}function w(e){const t=getComputedStyle(e),i=t[a],o=t[n],r=o.includes("ms")?1:1e3,s=g&&i&&"none"!==i?parseFloat(o)*r:0;return Number.isNaN(s)?0:s}function k(e){const n=getComputedStyle(e),t=n[r],i=n[s],a=i.includes("ms")?1:1e3,o=v&&t&&"none"!==t?parseFloat(i)*a:0;return Number.isNaN(o)?0:o}function z(e){const n=getComputedStyle(e),t=n[r],i=n[o],a=i.includes("ms")?1:1e3,s=v&&t&&"none"!==t?parseFloat(i)*a:0;return Number.isNaN(s)?0:s}function T(e){return"true"===e||"false"!==e&&(Number.isNaN(+e)?""===e||"null"===e?null:e:+e)}const L={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",mouseClickEvents:{down:"mousedown",up:"mouseup"},mouseHoverEvents:e,touchEvents:{start:"touchstart",end:"touchend",move:"touchmove",cancel:"touchcancel"},focusEvents:{in:"focusin",out:"focusout"},mouseSwipeEvents:{start:"mousedown",end:"mouseup",move:"mousemove",cancel:"mouseout"},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:n,animationDelay:t,animationName:a,animationEndEvent:i,transitionDuration:o,transitionDelay:s,transitionEndEvent:u,transitionProperty:r,isMobile:l,support3DTransform:m,supportPassive:b,supportTransform:p,supportTouch:E,supportAnimation:g,supportTransition:v,addEventListener:"addEventListener",removeEventListener:"removeEventListener",addClass:function(e,n){e.classList.add(n)},removeClass:function(e,n){e.classList.remove(n)},hasClass:function(e,n){return e.classList.contains(n)},on:f,off:y,one:function(e,n,t,i){f(e,n,(function a(o){o.target===e&&(t.apply(e,[o]),y(e,n,a,i))}),i)},emulateAnimationEnd:function(e,n){let t=0;const a=new Event(i),o=w(e),r=h(e);if(o){const s=a=>{a.target===e&&(n.apply(e,[a]),e.removeEventListener(i,s),t=1)};e.addEventListener(i,s),setTimeout(()=>{t||e.dispatchEvent(a)},o+r+17)}else n.apply(e,[a])},emulateTransitionEnd:function(e,n){let t=0;const i=new Event(u),a=z(e),o=k(e);if(a){const r=i=>{i.target===e&&(n.apply(e,[i]),e.removeEventListener(u,r),t=1)};e.addEventListener(u,r),setTimeout(()=>{t||e.dispatchEvent(i)},a+o+17)}else n.apply(e,[i])},isElementInScrollRange:function(e){const n=e.getBoundingClientRect(),t=window.innerHeight||document.documentElement.clientHeight;return n.top<=t&&n.bottom>=0},isElementInViewport:function(e){const n=e.getBoundingClientRect();return n.top>=0&&n.left>=0&&n.bottom<=(window.innerHeight||document.documentElement.clientHeight)&&n.right<=(window.innerWidth||document.documentElement.clientWidth)},passiveHandler:!!b&&{passive:!0},getElementAnimationDuration:w,getElementAnimationDelay:h,getElementTransitionDuration:z,getElementTransitionDelay:k,isElement:function(e){return e instanceof Element},isHTMLElement:function(e){return e instanceof HTMLElement},isMedia:function(e){return[SVGElement,HTMLImageElement,HTMLVideoElement].some(n=>e instanceof n)},isRTL:()=>"rtl"===document.documentElement.dir,queryElement:function(e,n){const t=n&&n instanceof Element?n:document;return e instanceof Element?e:t.querySelector(e)},normalizeValue:T,normalizeOptions:function(e,n,t,i){const a={...e.dataset},o={},r={};return Object.keys(a).forEach(e=>{const n=e.includes(i)?e.replace(i,"").replace(/[A-Z]/,e=>e.toLowerCase()):e;r[n]=T(a[e])}),Object.keys(t).forEach(e=>{t[e]=T(t[e])}),Object.keys(n).forEach(e=>{o[e]=e in t?t[e]:e in r?r[e]:n[e]}),o},tryWrapper:function(e,n){try{e()}catch(e){throw TypeError(`${n} ${e}`)}},reflow:function(e){return e.offsetHeight},Version:"0.2.13"};export default L;
// shorter-js v0.2.14 | dnp_theme © 2021 | MIT-License
const e="onmouseleave"in document?["mouseenter","mouseleave"]:["mouseover","mouseout"],n="webkitAnimation"in document.head.style?"webkitAnimationDuration":"animationDuration",t="webkitAnimation"in document.head.style?"webkitAnimationDelay":"animationDelay",i="webkitAnimation"in document.head.style?"webkitAnimationEnd":"animationend",a="webkitAnimation"in document.head.style?"webkitAnimationName":"animationName",o="webkitTransition"in document.head.style?"webkitTransitionDuration":"transitionDuration",r="webkitTransition"in document.head.style?"webkitTransitionProperty":"transitionProperty",s="webkitTransition"in document.head.style?"webkitTransitionDelay":"transitionDelay",u="webkitTransition"in document.head.style?"webkitTransitionEnd":"transitionend",c=/iPhone|iPad|iPod|Android/i;let d=!1;d=navigator.userAgentData?navigator.userAgentData.brands.some(e=>c.test(e.brand)):c.test(navigator.userAgent);const l=d,m=/(iPhone|iPod|iPad)/,{userAgentData:b}=navigator,g=b?b.brands.some(e=>m.test(e.brand)):m.test(navigator.userAgent),p="webkitPerspective"in document.head.style||"perspective"in document.head.style,E=(()=>{let e=!1;try{const n=Object.defineProperty({},"passive",{get:()=>(e=!0,e)});document.addEventListener("DOMContentLoaded",(function e(){document.removeEventListener("DOMContentLoaded",e,n)}),n)}catch(e){throw Error("Passive events are not supported")}return e})(),v="webkitTransform"in document.head.style||"transform"in document.head.style,h="ontouchstart"in window||"msMaxTouchPoints"in navigator,f="webkitAnimation"in document.head.style||"animation"in document.head.style,y="webkitTransition"in document.head.style||"transition"in document.head.style;function w(e,n,t,i){const a=i||!1;e.addEventListener(n,t,a)}function k(e,n,t,i){const a=i||!1;e.removeEventListener(n,t,a)}function z(e){return e instanceof Element}function T(e,n){const t=n&&z(n)?n:document;return z(e)?e:t.querySelector(e)}const L=new Map,D={set:(e,n,t)=>{const i=T(e);if(!z(i))return;L.has(n)||L.set(n,new Map);L.get(n).set(i,t)},getAllFor:e=>L.has(e)?L.get(e):null,get:(e,n)=>{const t=T(e),i=D.getAllFor(n);return i&&z(t)&&i.has(t)?i.get(t):null},remove:(e,n)=>{if(!L.has(n))return;const t=L.get(n);t.delete(e),0===t.size&&L.delete(n)}};function A(e){const n=getComputedStyle(e),i=n[a],o=n[t],r=o.includes("ms")?1:1e3,s=f&&i&&"none"!==i?parseFloat(o)*r:0;return Number.isNaN(s)?0:s}function O(e){const t=getComputedStyle(e),i=t[a],o=t[n],r=o.includes("ms")?1:1e3,s=f&&i&&"none"!==i?parseFloat(o)*r:0;return Number.isNaN(s)?0:s}function C(e){const n=getComputedStyle(e),t=n[r],i=n[s],a=i.includes("ms")?1:1e3,o=y&&t&&"none"!==t?parseFloat(i)*a:0;return Number.isNaN(o)?0:o}function I(e){const n=getComputedStyle(e),t=n[r],i=n[o],a=i.includes("ms")?1:1e3,s=y&&t&&"none"!==t?parseFloat(i)*a:0;return Number.isNaN(s)?0:s}function N(e){return"true"===e||"false"!==e&&(Number.isNaN(+e)?""===e||"null"===e?null:e:+e)}const P={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",mouseClickEvents:{down:"mousedown",up:"mouseup"},mouseHoverEvents:e,touchEvents:{start:"touchstart",end:"touchend",move:"touchmove",cancel:"touchcancel"},focusEvents:{in:"focusin",out:"focusout"},mouseSwipeEvents:{start:"mousedown",end:"mouseup",move:"mousemove",cancel:"mouseout"},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:n,animationDelay:t,animationName:a,animationEndEvent:i,transitionDuration:o,transitionDelay:s,transitionEndEvent:u,transitionProperty:r,isMobile:l,isApple:g,support3DTransform:p,supportPassive:E,supportTransform:v,supportTouch:h,supportAnimation:f,supportTransition:y,addEventListener:"addEventListener",removeEventListener:"removeEventListener",addClass:function(e,n){e.classList.add(n)},removeClass:function(e,n){e.classList.remove(n)},hasClass:function(e,n){return e.classList.contains(n)},on:w,off:k,one:function(e,n,t,i){w(e,n,(function a(o){o.target===e&&(t.apply(e,[o]),k(e,n,a,i))}),i)},Data:D,getInstance:(e,n)=>D.get(e,n),emulateAnimationEnd:function(e,n){let t=0;const a=new Event(i),o=O(e),r=A(e);if(o){const s=a=>{a.target===e&&(n.apply(e,[a]),e.removeEventListener(i,s),t=1)};e.addEventListener(i,s),setTimeout(()=>{t||e.dispatchEvent(a)},o+r+17)}else n.apply(e,[a])},emulateTransitionEnd:function(e,n){let t=0;const i=new Event(u),a=I(e),o=C(e);if(a){const r=i=>{i.target===e&&(n.apply(e,[i]),e.removeEventListener(u,r),t=1)};e.addEventListener(u,r),setTimeout(()=>{t||e.dispatchEvent(i)},a+o+17)}else n.apply(e,[i])},isElementInScrollRange:function(e){const n=e.getBoundingClientRect(),t=window.innerHeight||document.documentElement.clientHeight;return n.top<=t&&n.bottom>=0},isElementInViewport:function(e){const n=e.getBoundingClientRect();return n.top>=0&&n.left>=0&&n.bottom<=(window.innerHeight||document.documentElement.clientHeight)&&n.right<=(window.innerWidth||document.documentElement.clientWidth)},passiveHandler:!!E&&{passive:!0},getElementAnimationDuration:O,getElementAnimationDelay:A,getElementTransitionDuration:I,getElementTransitionDelay:C,isElement:z,isHTMLElement:function(e){return e instanceof HTMLElement},isMedia:function(e){return[SVGElement,HTMLImageElement,HTMLVideoElement].some(n=>e instanceof n)},isRTL:()=>"rtl"===document.documentElement.dir,queryElement:T,normalizeValue:N,normalizeOptions:function(e,n,t,i){const a={...e.dataset},o={},r={};return Object.keys(a).forEach(e=>{const n=e.includes(i)?e.replace(i,"").replace(/[A-Z]/,e=>e.toLowerCase()):e;r[n]=N(a[e])}),Object.keys(t).forEach(e=>{t[e]=N(t[e])}),Object.keys(n).forEach(e=>{o[e]=e in t?t[e]:e in r?r[e]:n[e]}),o},tryWrapper:function(e,n){try{e()}catch(e){throw TypeError(`${n} ${e}`)}},reflow:function(e){return e.offsetHeight},Version:"0.2.14"};export default P;
/*!
* shorter-js v0.2.13 (https://github.com/thednp/shorter-js)
* shorter-js v0.2.14 (https://github.com/thednp/shorter-js)
* Copyright 2019-2021 © dnp_theme

@@ -210,3 +210,13 @@ * Licensed under MIT (https://github.com/thednp/shorter-js/blob/master/LICENSE)

var appleBrands = /(iPhone|iPod|iPad)/;
/**
* A global namespace for Apple browsers.
*/
// @ts-ignore
var userAgentData = navigator.userAgentData;
var isApple = !userAgentData ? appleBrands.test(navigator.userAgent)
: userAgentData.brands.some(function (x) { return appleBrands.test(x.brand); });
/**
* A global namespace for CSS3 3D transform support.

@@ -345,2 +355,103 @@ * @type {boolean}

/**
* Checks if an element is an `Element`.
*
* @param {any} element the target element
* @returns {boolean} the query result
*/
function isElement(element) {
return element instanceof Element;
}
/**
* Utility to check if target is typeof Element
* or find one that matches a selector.
*
* @param {Element | string} selector the input selector or target element
* @param {Element=} parent optional Element to look into
* @return {Element?} the Element or `querySelector` result
*/
function queryElement(selector, parent) {
var lookUp = parent && isElement(parent) ? parent : document;
// @ts-ignore
return isElement(selector) ? selector : lookUp.querySelector(selector);
}
var componentData = new Map();
/**
* An interface for web components background data.
* @see https://github.com/thednp/bootstrap.native/blob/master/src/components/base-component.js
*/
var Data = {
/**
* Sets web components data.
* @param {Element | string} element target element
* @param {string} component the component's name or a unique key
* @param {Record<string, any>} instance the component instance
*/
set: function (element, component, instance) {
var ELEMENT = queryElement(element);
if (!isElement(ELEMENT)) { return; }
if (!componentData.has(component)) {
componentData.set(component, new Map());
}
var instanceMap = componentData.get(component);
instanceMap.set(ELEMENT, instance);
},
/**
* Returns all instances for specified component.
* @param {string} component the component's name or a unique key
* @returns {any?} all the component instances
*/
getAllFor: function (component) {
if (componentData.has(component)) {
return componentData.get(component);
}
return null;
},
/**
* Returns the instance associated with the target.
* @param {Element | string} element target element
* @param {string} component the component's name or a unique key
* @returns {any?} the instance
*/
get: function (element, component) {
var ELEMENT = queryElement(element);
var allForC = Data.getAllFor(component);
if (allForC && isElement(ELEMENT) && allForC.has(ELEMENT)) {
return allForC.get(ELEMENT);
}
return null;
},
/**
* Removes web components data.
* @param {Element} element target element
* @param {string} component the component's name or a unique key
*/
remove: function (element, component) {
if (!componentData.has(component)) { return; }
var instanceMap = componentData.get(component);
instanceMap.delete(element);
if (instanceMap.size === 0) {
componentData.delete(component);
}
},
};
/**
* An alias for `Data.get()`.
* @param {Element} element target element
* @param {string} component the component's name or a unique key
* @returns {any} the request result
*/
var getInstance = function (element, component) { return Data.get(element, component); };
/**
* Utility to get the computed animationDelay

@@ -528,12 +639,2 @@ * from Element in miliseconds.

/**
* Checks if an element is an `Element`.
*
* @param {any} element the target element
* @returns {boolean} the query result
*/
function isElement(element) {
return element instanceof Element;
}
/**
* Checks if an element is an `<svg>`, `<img>` or `<video>`.

@@ -563,15 +664,2 @@ * *Tooltip* / *Popover* works different with media elements.

/**
* Utility to check if target is typeof Element
* or find one that matches a selector.
*
* @param {Element | string} selector the input selector or target element
* @param {Element | null} parent optional Element to look into
* @return {Element | null} the Element or result of the querySelector
*/
function queryElement(selector, parent) {
var lookUp = parent && parent instanceof Element ? parent : document;
return selector instanceof Element ? selector : lookUp.querySelector(selector);
}
/**
* The raw value or a given component option.

@@ -675,3 +763,3 @@ *

var version = "0.2.13";
var version = "0.2.14";

@@ -713,2 +801,3 @@ // @ts-ignore

isMobile: isMobile,
isApple: isApple,
support3DTransform: support3DTransform,

@@ -728,2 +817,4 @@ supportPassive: supportPassive,

one: one,
Data: Data,
getInstance: getInstance,
emulateAnimationEnd: emulateAnimationEnd,

@@ -730,0 +821,0 @@ emulateTransitionEnd: emulateTransitionEnd,

@@ -1,2 +0,2 @@

// shorter-js v0.2.13 | dnp_theme © 2021 | MIT-License
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e=e||self).SHORTER=n()}(this,(function(){"use strict";var e="onmouseleave"in document?["mouseenter","mouseleave"]:["mouseover","mouseout"],n="webkitAnimation"in document.head.style?"webkitAnimationDuration":"animationDuration",t="webkitAnimation"in document.head.style?"webkitAnimationDelay":"animationDelay",i="webkitAnimation"in document.head.style?"webkitAnimationEnd":"animationend",a="webkitAnimation"in document.head.style?"webkitAnimationName":"animationName",o="webkitTransition"in document.head.style?"webkitTransitionDuration":"transitionDuration",r="webkitTransition"in document.head.style?"webkitTransitionProperty":"transitionProperty",u="webkitTransition"in document.head.style?"webkitTransitionDelay":"transitionDelay",s="webkitTransition"in document.head.style?"webkitTransitionEnd":"transitionend",c=/iPhone|iPad|iPod|Android/i,d=navigator.userAgentData?navigator.userAgentData.brands.some((function(e){return c.test(e.brand)})):c.test(navigator.userAgent),m="webkitPerspective"in document.head.style||"perspective"in document.head.style,l=function(){var e=!1;try{var n=Object.defineProperty({},"passive",{get:function(){return e=!0}});document.addEventListener("DOMContentLoaded",(function e(){document.removeEventListener("DOMContentLoaded",e,n)}),n)}catch(e){throw Error("Passive events are not supported")}return e}(),b="webkitTransform"in document.head.style||"transform"in document.head.style,f="ontouchstart"in window||"msMaxTouchPoints"in navigator,v="webkitAnimation"in document.head.style||"animation"in document.head.style,p="webkitTransition"in document.head.style||"transition"in document.head.style;function E(e,n,t,i){var a=i||!1;e.addEventListener(n,t,a)}function g(e,n,t,i){var a=i||!1;e.removeEventListener(n,t,a)}function y(e){var n=getComputedStyle(e),i=n[a],o=n[t],r=o.includes("ms")?1:1e3,u=v&&i&&"none"!==i?parseFloat(o)*r:0;return Number.isNaN(u)?0:u}function h(e){var t=getComputedStyle(e),i=t[a],o=t[n],r=o.includes("ms")?1:1e3,u=v&&i&&"none"!==i?parseFloat(o)*r:0;return Number.isNaN(u)?0:u}function w(e){var n=getComputedStyle(e),t=n[r],i=n[u],a=i.includes("ms")?1:1e3,o=p&&t&&"none"!==t?parseFloat(i)*a:0;return Number.isNaN(o)?0:o}function k(e){var n=getComputedStyle(e),t=n[r],i=n[o],a=i.includes("ms")?1:1e3,u=p&&t&&"none"!==t?parseFloat(i)*a:0;return Number.isNaN(u)?0:u}function z(e){return"true"===e||"false"!==e&&(Number.isNaN(+e)?""===e||"null"===e?null:e:+e)}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",mouseClickEvents:{down:"mousedown",up:"mouseup"},mouseHoverEvents:e,touchEvents:{start:"touchstart",end:"touchend",move:"touchmove",cancel:"touchcancel"},focusEvents:{in:"focusin",out:"focusout"},mouseSwipeEvents:{start:"mousedown",end:"mouseup",move:"mousemove",cancel:"mouseout"},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:n,animationDelay:t,animationName:a,animationEndEvent:i,transitionDuration:o,transitionDelay:u,transitionEndEvent:s,transitionProperty:r,isMobile:d,support3DTransform:m,supportPassive:l,supportTransform:b,supportTouch:f,supportAnimation:v,supportTransition:p,addEventListener:"addEventListener",removeEventListener:"removeEventListener",addClass:function(e,n){e.classList.add(n)},removeClass:function(e,n){e.classList.remove(n)},hasClass:function(e,n){return e.classList.contains(n)},on:E,off:g,one:function(e,n,t,i){E(e,n,(function a(o){o.target===e&&(t.apply(e,[o]),g(e,n,a,i))}),i)},emulateAnimationEnd:function(e,n){var t=0,a=new Event(i),o=h(e),r=y(e);if(o){var u=function(a){a.target===e&&(n.apply(e,[a]),e.removeEventListener(i,u),t=1)};e.addEventListener(i,u),setTimeout((function(){t||e.dispatchEvent(a)}),o+r+17)}else n.apply(e,[a])},emulateTransitionEnd:function(e,n){var t=0,i=new Event(s),a=k(e),o=w(e);if(a){var r=function(i){i.target===e&&(n.apply(e,[i]),e.removeEventListener(s,r),t=1)};e.addEventListener(s,r),setTimeout((function(){t||e.dispatchEvent(i)}),a+o+17)}else n.apply(e,[i])},isElementInScrollRange:function(e){var n=e.getBoundingClientRect(),t=window.innerHeight||document.documentElement.clientHeight;return n.top<=t&&n.bottom>=0},isElementInViewport:function(e){var n=e.getBoundingClientRect();return n.top>=0&&n.left>=0&&n.bottom<=(window.innerHeight||document.documentElement.clientHeight)&&n.right<=(window.innerWidth||document.documentElement.clientWidth)},passiveHandler:!!l&&{passive:!0},getElementAnimationDuration:h,getElementAnimationDelay:y,getElementTransitionDuration:k,getElementTransitionDelay:w,isElement:function(e){return e instanceof Element},isHTMLElement:function(e){return e instanceof HTMLElement},isMedia:function(e){return[SVGElement,HTMLImageElement,HTMLVideoElement].some((function(n){return e instanceof n}))},isRTL:function(){return"rtl"===document.documentElement.dir},queryElement:function(e,n){var t=n&&n instanceof Element?n:document;return e instanceof Element?e:t.querySelector(e)},normalizeValue:z,normalizeOptions:function(e,n,t,i){var a=Object.assign({},e.dataset),o={},r={};return Object.keys(a).forEach((function(e){var n=e.includes(i)?e.replace(i,"").replace(/[A-Z]/,(function(e){return e.toLowerCase()})):e;r[n]=z(a[e])})),Object.keys(t).forEach((function(e){t[e]=z(t[e])})),Object.keys(n).forEach((function(e){o[e]=e in t?t[e]:e in r?r[e]:n[e]})),o},tryWrapper:function(e,n){try{e()}catch(e){throw TypeError(n+" "+e)}},reflow:function(e){return e.offsetHeight},Version:"0.2.13"}}));
// shorter-js v0.2.14 | dnp_theme © 2021 | MIT-License
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e=e||self).SHORTER=n()}(this,(function(){"use strict";var e="onmouseleave"in document?["mouseenter","mouseleave"]:["mouseover","mouseout"],n="webkitAnimation"in document.head.style?"webkitAnimationDuration":"animationDuration",t="webkitAnimation"in document.head.style?"webkitAnimationDelay":"animationDelay",i="webkitAnimation"in document.head.style?"webkitAnimationEnd":"animationend",a="webkitAnimation"in document.head.style?"webkitAnimationName":"animationName",r="webkitTransition"in document.head.style?"webkitTransitionDuration":"transitionDuration",o="webkitTransition"in document.head.style?"webkitTransitionProperty":"transitionProperty",u="webkitTransition"in document.head.style?"webkitTransitionDelay":"transitionDelay",s="webkitTransition"in document.head.style?"webkitTransitionEnd":"transitionend",c=/iPhone|iPad|iPod|Android/i,d=navigator.userAgentData?navigator.userAgentData.brands.some((function(e){return c.test(e.brand)})):c.test(navigator.userAgent),l=/(iPhone|iPod|iPad)/,m=navigator.userAgentData,b=m?m.brands.some((function(e){return l.test(e.brand)})):l.test(navigator.userAgent),f="webkitPerspective"in document.head.style||"perspective"in document.head.style,v=function(){var e=!1;try{var n=Object.defineProperty({},"passive",{get:function(){return e=!0}});document.addEventListener("DOMContentLoaded",(function e(){document.removeEventListener("DOMContentLoaded",e,n)}),n)}catch(e){throw Error("Passive events are not supported")}return e}(),p="webkitTransform"in document.head.style||"transform"in document.head.style,g="ontouchstart"in window||"msMaxTouchPoints"in navigator,E="webkitAnimation"in document.head.style||"animation"in document.head.style,y="webkitTransition"in document.head.style||"transition"in document.head.style;function h(e,n,t,i){var a=i||!1;e.addEventListener(n,t,a)}function w(e,n,t,i){var a=i||!1;e.removeEventListener(n,t,a)}function k(e){return e instanceof Element}function z(e,n){var t=n&&k(n)?n:document;return k(e)?e:t.querySelector(e)}var T=new Map,L={set:function(e,n,t){var i=z(e);k(i)&&(T.has(n)||T.set(n,new Map),T.get(n).set(i,t))},getAllFor:function(e){return T.has(e)?T.get(e):null},get:function(e,n){var t=z(e),i=L.getAllFor(n);return i&&k(t)&&i.has(t)?i.get(t):null},remove:function(e,n){if(T.has(n)){var t=T.get(n);t.delete(e),0===t.size&&T.delete(n)}}};function O(e){var n=getComputedStyle(e),i=n[a],r=n[t],o=r.includes("ms")?1:1e3,u=E&&i&&"none"!==i?parseFloat(r)*o:0;return Number.isNaN(u)?0:u}function D(e){var t=getComputedStyle(e),i=t[a],r=t[n],o=r.includes("ms")?1:1e3,u=E&&i&&"none"!==i?parseFloat(r)*o:0;return Number.isNaN(u)?0:u}function A(e){var n=getComputedStyle(e),t=n[o],i=n[u],a=i.includes("ms")?1:1e3,r=y&&t&&"none"!==t?parseFloat(i)*a:0;return Number.isNaN(r)?0:r}function C(e){var n=getComputedStyle(e),t=n[o],i=n[r],a=i.includes("ms")?1:1e3,u=y&&t&&"none"!==t?parseFloat(i)*a:0;return Number.isNaN(u)?0:u}function I(e){return"true"===e||"false"!==e&&(Number.isNaN(+e)?""===e||"null"===e?null:e:+e)}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",mouseClickEvents:{down:"mousedown",up:"mouseup"},mouseHoverEvents:e,touchEvents:{start:"touchstart",end:"touchend",move:"touchmove",cancel:"touchcancel"},focusEvents:{in:"focusin",out:"focusout"},mouseSwipeEvents:{start:"mousedown",end:"mouseup",move:"mousemove",cancel:"mouseout"},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:n,animationDelay:t,animationName:a,animationEndEvent:i,transitionDuration:r,transitionDelay:u,transitionEndEvent:s,transitionProperty:o,isMobile:d,isApple:b,support3DTransform:f,supportPassive:v,supportTransform:p,supportTouch:g,supportAnimation:E,supportTransition:y,addEventListener:"addEventListener",removeEventListener:"removeEventListener",addClass:function(e,n){e.classList.add(n)},removeClass:function(e,n){e.classList.remove(n)},hasClass:function(e,n){return e.classList.contains(n)},on:h,off:w,one:function(e,n,t,i){h(e,n,(function a(r){r.target===e&&(t.apply(e,[r]),w(e,n,a,i))}),i)},Data:L,getInstance:function(e,n){return L.get(e,n)},emulateAnimationEnd:function(e,n){var t=0,a=new Event(i),r=D(e),o=O(e);if(r){var u=function(a){a.target===e&&(n.apply(e,[a]),e.removeEventListener(i,u),t=1)};e.addEventListener(i,u),setTimeout((function(){t||e.dispatchEvent(a)}),r+o+17)}else n.apply(e,[a])},emulateTransitionEnd:function(e,n){var t=0,i=new Event(s),a=C(e),r=A(e);if(a){var o=function(i){i.target===e&&(n.apply(e,[i]),e.removeEventListener(s,o),t=1)};e.addEventListener(s,o),setTimeout((function(){t||e.dispatchEvent(i)}),a+r+17)}else n.apply(e,[i])},isElementInScrollRange:function(e){var n=e.getBoundingClientRect(),t=window.innerHeight||document.documentElement.clientHeight;return n.top<=t&&n.bottom>=0},isElementInViewport:function(e){var n=e.getBoundingClientRect();return n.top>=0&&n.left>=0&&n.bottom<=(window.innerHeight||document.documentElement.clientHeight)&&n.right<=(window.innerWidth||document.documentElement.clientWidth)},passiveHandler:!!v&&{passive:!0},getElementAnimationDuration:D,getElementAnimationDelay:O,getElementTransitionDuration:C,getElementTransitionDelay:A,isElement:k,isHTMLElement:function(e){return e instanceof HTMLElement},isMedia:function(e){return[SVGElement,HTMLImageElement,HTMLVideoElement].some((function(n){return e instanceof n}))},isRTL:function(){return"rtl"===document.documentElement.dir},queryElement:z,normalizeValue:I,normalizeOptions:function(e,n,t,i){var a=Object.assign({},e.dataset),r={},o={};return Object.keys(a).forEach((function(e){var n=e.includes(i)?e.replace(i,"").replace(/[A-Z]/,(function(e){return e.toLowerCase()})):e;o[n]=I(a[e])})),Object.keys(t).forEach((function(e){t[e]=I(t[e])})),Object.keys(n).forEach((function(e){r[e]=e in t?t[e]:e in o?o[e]:n[e]})),r},tryWrapper:function(e,n){try{e()}catch(e){throw TypeError(n+" "+e)}},reflow:function(e){return e.offsetHeight},Version:"0.2.14"}}));
{
"name": "shorter-js",
"version": "0.2.13",
"version": "0.2.14",
"description": "A small ES6+ library with various JavaScript tools useful for creating light libraries.",

@@ -10,6 +10,5 @@ "main": "dist/shorter-js.min.js",

"files": [
"dist/*.{js,map}",
"src/**/*.{js,map}",
"types/**/*.{ts,map}",
"types/*.{ts,map}"
"dist",
"src",
"types"
],

@@ -16,0 +15,0 @@ "scripts": {

@@ -31,2 +31,3 @@ // strings FIRST

import isMobile from './boolean/isMobile';
import isApple from './boolean/isApple';
import support3DTransform from './boolean/support3DTransform';

@@ -50,2 +51,3 @@ import supportPassive from './boolean/supportPassive';

// misc
import Data, { getInstance } from './misc/data';
import emulateAnimationEnd from './misc/emulateAnimationEnd';

@@ -97,2 +99,3 @@ import emulateTransitionEnd from './misc/emulateTransitionEnd';

isMobile,
isApple,
support3DTransform,

@@ -112,2 +115,4 @@ supportPassive,

one,
Data,
getInstance,
emulateAnimationEnd,

@@ -114,0 +119,0 @@ emulateTransitionEnd,

@@ -0,1 +1,4 @@

import queryElement from './queryElement';
import isElement from './isElement';
const componentData = new Map();

@@ -9,3 +12,3 @@ /**

* Sets web components data.
* @param {Element} element target element
* @param {Element | string} element target element
* @param {string} component the component's name or a unique key

@@ -15,2 +18,5 @@ * @param {any} instance the component instance

set: (element, component, instance) => {
const ELEMENT = queryElement(element);
if (!isElement(ELEMENT)) return;
if (!componentData.has(component)) {

@@ -21,3 +27,3 @@ componentData.set(component, new Map());

const instanceMap = componentData.get(component);
instanceMap.set(element, instance);
instanceMap.set(ELEMENT, instance);
},

@@ -28,7 +34,7 @@

* @param {string} component the component's name or a unique key
* @returns {?any} all the component instances
* @returns {any?} all the component instances
*/
getAllFor: (component) => {
if (componentData.has(component)) {
return componentData.get(component) || null;
return componentData.get(component);
}

@@ -40,10 +46,12 @@ return null;

* Returns the instance associated with the target.
* @param {Element} element target element
* @param {Element | string} element target element
* @param {string} component the component's name or a unique key
* @returns {?any} the instance
* @returns {any?} the instance
*/
get: (element, component) => {
const ELEMENT = queryElement(element);
const allForC = Data.getAllFor(component);
if (allForC && allForC.has(element)) {
return allForC.get(element) || null;
if (allForC && isElement(ELEMENT) && allForC.has(ELEMENT)) {
return allForC.get(ELEMENT);
}

@@ -57,3 +65,2 @@ return null;

* @param {string} component the component's name or a unique key
* @param {any} instance the component instance
*/

@@ -73,4 +80,6 @@ remove: (element, component) => {

/**
* Shortcut for `Data.get(a, b)` to setup usable component static method.
* @type {SHORTER.getInstance<SHORTER.Component, string>}
* An alias for `Data.get()`.
* @param {Element} element target element
* @param {string} component the component's name or a unique key
* @returns {any} the request result
*/

@@ -77,0 +86,0 @@ export const getInstance = (element, component) => Data.get(element, component);

@@ -0,1 +1,3 @@

import isElement from './isElement';
/**

@@ -6,8 +8,9 @@ * Utility to check if target is typeof Element

* @param {Element | string} selector the input selector or target element
* @param {Element | null} parent optional Element to look into
* @return {Element | null} the Element or result of the querySelector
* @param {Element=} parent optional Element to look into
* @return {Element?} the Element or `querySelector` result
*/
export default function queryElement(selector, parent) {
const lookUp = parent && parent instanceof Element ? parent : document;
return selector instanceof Element ? selector : lookUp.querySelector(selector);
const lookUp = parent && isElement(parent) ? parent : document;
// @ts-ignore
return isElement(selector) ? selector : lookUp.querySelector(selector);
}

@@ -19,2 +19,3 @@ export as namespace SHORTER;

export { default as isMobile } from "shorter-js/src/boolean/isMobile";
export { default as isApple } from "shorter-js/src/boolean/isApple";
export { default as support3DTransform } from "shorter-js/src/boolean/support3DTransform";

@@ -51,8 +52,1 @@ export { default as supportPassive } from "shorter-js/src/boolean/supportPassive";

export { default as Version } from "shorter-js/src/misc/version";
export interface Component {
element: Element,
options?: Record<string, any>,
}
export type getInstance<T, C> = (element: Element, component: C) => T | null;

@@ -25,2 +25,3 @@ export { default as ariaChecked } from "../../src/strings/ariaChecked";

export { default as isMobile } from "../../src/boolean/isMobile";
export { default as isApple } from "../../src/boolean/isApple";
export { default as support3DTransform } from "../../src/boolean/support3DTransform";

@@ -27,0 +28,0 @@ export { default as supportPassive } from "../../src/boolean/supportPassive";

@@ -331,13 +331,29 @@ declare module "shorter-js/src/strings/ariaChecked" {

}
declare module "shorter-js/src/misc/data" {
declare module "shorter-js/src/misc/isElement" {
/**
* Shortcut for `Data.get(a, b)` to setup usable component static method.
* @type {SHORTER.getInstance<SHORTER.Component, string>}
* Checks if an element is an `Element`.
*
* @param {any} element the target element
* @returns {boolean} the query result
*/
export const getInstance: SHORTER.getInstance<SHORTER.Component, string>;
export default function isElement(element: any): boolean;
}
declare module "shorter-js/src/misc/queryElement" {
/**
* Utility to check if target is typeof Element
* or find one that matches a selector.
*
* @param {Element | string} selector the input selector or target element
* @param {Element=} parent optional Element to look into
* @return {Element?} the Element or `querySelector` result
*/
export default function queryElement(selector: Element | string, parent?: Element | undefined): Element | null;
}
declare module "shorter-js/src/misc/data" {
export function getInstance(element: Element, component: string): any;
export default Data;
namespace Data {
function set(element: Element, component: string, instance: any): void;
function set(element: string | Element, component: string, instance: any): void;
function getAllFor(component: string): any;
function get(element: Element, component: string): any;
function get(element: string | Element, component: string): any;
function remove(element: Element, component: string): void;

@@ -406,10 +422,5 @@ }

}
declare module "shorter-js/src/misc/isElement" {
/**
* Checks if an element is an `Element`.
*
* @param {any} element the target element
* @returns {boolean} the query result
*/
export default function isElement(element: any): boolean;
declare module "shorter-js/src/boolean/isApple" {
export default isApple;
const isApple: any;
}

@@ -471,13 +482,2 @@ declare module "shorter-js/src/misc/isElementInScrollRange" {

}
declare module "shorter-js/src/misc/queryElement" {
/**
* Utility to check if target is typeof Element
* or find one that matches a selector.
*
* @param {Element | string} selector the input selector or target element
* @param {Element | null} parent optional Element to look into
* @return {Element | null} the Element or result of the querySelector
*/
export default function queryElement(selector: Element | string, parent: Element | null): Element | null;
}
declare module "shorter-js/src/misc/normalizeValue" {

@@ -581,2 +581,3 @@ /**

export { default as emulateTransitionEnd } from "shorter-js/src/misc/emulateTransitionEnd";
export { default as isApple } from "shorter-js/src/boolean/isApple";
export { default as isElement } from "shorter-js/src/misc/isElement";

@@ -583,0 +584,0 @@ export { default as isElementInScrollRange } from "shorter-js/src/misc/isElementInScrollRange";

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc