@thednp/shorty 1.0.3 → 2.0.0-alpha10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.cjs +224 -0
- package/.lgtm.yml +9 -0
- package/.prettierrc.json +15 -0
- package/README.md +195 -198
- package/cypress/e2e/att.cy.ts +46 -0
- package/cypress/e2e/boolean.cy.ts +44 -0
- package/cypress/e2e/class.cy.ts +28 -0
- package/cypress/e2e/event.cy.ts +51 -0
- package/cypress/e2e/get.cy.ts +168 -0
- package/cypress/e2e/is.cy.ts +233 -0
- package/cypress/e2e/misc.cy.ts +331 -0
- package/cypress/e2e/selectors.cy.ts +85 -0
- package/cypress/fixtures/custom-elem.js +18 -0
- package/cypress/plugins/esbuild-istanbul.ts +50 -0
- package/cypress/plugins/tsCompile.ts +34 -0
- package/cypress/support/commands.ts +37 -0
- package/cypress/support/e2e.ts +21 -0
- package/cypress/support/index.js +22 -0
- package/cypress/test.html +63 -0
- package/cypress.config.ts +30 -0
- package/dist/shorty.cjs +2 -0
- package/dist/shorty.cjs.map +1 -0
- package/dist/shorty.d.ts +1502 -0
- package/dist/shorty.js +2 -2628
- package/dist/shorty.js.map +1 -0
- package/dist/shorty.mjs +552 -0
- package/dist/shorty.mjs.map +1 -0
- package/dts.config.ts +22 -0
- package/package.json +33 -38
- package/src/attr/getAttribute.ts +11 -0
- package/src/attr/getAttributeNS.ts +12 -0
- package/src/attr/hasAttribute.ts +10 -0
- package/src/attr/hasAttributeNS.ts +12 -0
- package/src/attr/removeAttribute.ts +9 -0
- package/src/attr/removeAttributeNS.ts +11 -0
- package/src/attr/setAttribute.ts +11 -0
- package/src/attr/setAttributeNS.ts +12 -0
- package/src/blocks/{documentBody.js → documentBody.ts} +0 -0
- package/src/blocks/{documentElement.js → documentElement.ts} +0 -0
- package/src/blocks/{documentHead.js → documentHead.ts} +0 -0
- package/src/boolean/isApple.ts +14 -0
- package/src/boolean/{isFirefox.js → isFirefox.ts} +2 -3
- package/src/boolean/{isMobile.js → isMobile.ts} +1 -2
- package/src/boolean/support3DTransform.ts +8 -0
- package/src/boolean/supportAnimation.ts +8 -0
- package/src/boolean/{supportPassive.js → supportPassive.ts} +3 -3
- package/src/boolean/supportTouch.ts +7 -0
- package/src/boolean/supportTransform.ts +8 -0
- package/src/boolean/supportTransition.ts +8 -0
- package/src/class/addClass.ts +11 -0
- package/src/class/hasClass.ts +11 -0
- package/src/class/removeClass.ts +11 -0
- package/src/event/off.ts +14 -0
- package/src/event/on.ts +14 -0
- package/src/event/one.ts +25 -0
- package/src/get/{getBoundingClientRect.js → getBoundingClientRect.ts} +14 -12
- package/src/get/{getDocument.js → getDocument.ts} +11 -7
- package/src/get/getDocumentBody.ts +13 -0
- package/src/get/getDocumentElement.ts +13 -0
- package/src/get/getDocumentHead.ts +12 -0
- package/src/get/{getElementAnimationDelay.js → getElementAnimationDelay.ts} +10 -9
- package/src/get/{getElementAnimationDuration.js → getElementAnimationDuration.ts} +10 -8
- package/src/get/getElementStyle.ts +25 -0
- package/src/get/{getElementTransitionDelay.js → getElementTransitionDelay.ts} +12 -8
- package/src/get/{getElementTransitionDuration.js → getElementTransitionDuration.ts} +12 -8
- package/src/get/{getNodeScroll.js → getNodeScroll.ts} +9 -5
- package/src/get/{getParentNode.js → getParentNode.ts} +11 -6
- package/src/get/{getRectRelativeToOffsetParent.js → getRectRelativeToOffsetParent.ts} +15 -7
- package/src/get/getUID.ts +42 -0
- package/src/get/{getWindow.js → getWindow.ts} +9 -6
- package/src/{index.js → index.ts} +37 -43
- package/src/interface/boundingClientRect.d.ts +10 -0
- package/src/interface/css4Declaration.d.ts +4 -0
- package/src/interface/customElement.d.ts +8 -0
- package/src/interface/navigatorUA.d.ts +15 -0
- package/src/interface/offsetRect.d.ts +6 -0
- package/src/interface/originalEvent.d.ts +4 -0
- package/src/is/isArray.ts +9 -0
- package/src/is/isCanvas.ts +13 -0
- package/src/is/isCustomElement.ts +13 -0
- package/src/is/isDocument.ts +13 -0
- package/src/is/{isElement.js → isElement.ts} +10 -5
- package/src/is/{isElementInScrollRange.js → isElementInScrollRange.ts} +4 -4
- package/src/is/{isElementInViewport.js → isElementInViewport.ts} +6 -12
- package/src/is/isElementsArray.ts +13 -0
- package/src/is/isFunction.ts +10 -0
- package/src/is/isHTMLCollection.ts +12 -0
- package/src/is/isHTMLElement.ts +13 -0
- package/src/is/isHTMLImageElement.ts +12 -0
- package/src/is/isJSON.ts +20 -0
- package/src/is/isMap.ts +11 -0
- package/src/is/isMedia.ts +20 -0
- package/src/is/isNode.ts +17 -0
- package/src/is/isNodeList.ts +13 -0
- package/src/is/isNumber.ts +9 -0
- package/src/is/isObject.ts +10 -0
- package/src/is/isRTL.ts +11 -0
- package/src/is/isSVGElement.ts +13 -0
- package/src/is/{isScaledElement.js → isScaledElement.ts} +9 -7
- package/src/is/isShadowRoot.ts +12 -0
- package/src/is/isString.ts +9 -0
- package/src/is/isTableElement.ts +14 -0
- package/src/is/isWeakMap.ts +11 -0
- package/src/is/isWindow.ts +13 -0
- package/src/misc/ArrayFrom.ts +11 -0
- package/src/misc/Float32ArrayFrom.ts +10 -0
- package/src/misc/Float64ArrayFrom.ts +10 -0
- package/src/misc/ObjectAssign.ts +43 -0
- package/src/misc/ObjectEntries.ts +11 -0
- package/src/misc/ObjectHasOwn.ts +17 -0
- package/src/misc/ObjectKeys.ts +10 -0
- package/src/misc/ObjectValues.ts +11 -0
- package/src/misc/createCustomEvent.ts +28 -0
- package/src/misc/createElement.ts +40 -0
- package/src/misc/createElementNS.ts +45 -0
- package/src/misc/data.ts +82 -0
- package/src/misc/dispatchEvent.ts +9 -0
- package/src/misc/distinct.ts +18 -0
- package/src/misc/{emulateAnimationEnd.js → emulateAnimationEnd.ts} +8 -9
- package/src/misc/{emulateTransitionEnd.js → emulateTransitionEnd.ts} +8 -9
- package/src/misc/focus.ts +9 -0
- package/src/misc/getInstance.ts +9 -0
- package/src/misc/{noop.js → noop.ts} +4 -1
- package/src/misc/normalizeOptions.ts +55 -0
- package/src/misc/normalizeValue.ts +30 -0
- package/src/misc/{passiveHandler.js → passiveHandler.ts} +1 -2
- package/src/misc/reflow.ts +9 -0
- package/src/misc/setElementStyle.ts +23 -0
- package/src/misc/timer.ts +84 -0
- package/src/misc/toLowerCase.ts +9 -0
- package/src/misc/toUpperCase.ts +9 -0
- package/src/selectors/closest.ts +20 -0
- package/src/selectors/{getCustomElements.js → getCustomElements.ts} +8 -4
- package/src/selectors/getElementById.ts +16 -0
- package/src/selectors/getElementsByClassName.ts +22 -0
- package/src/selectors/getElementsByTagName.ts +20 -0
- package/src/selectors/matches.ts +10 -0
- package/src/selectors/querySelector.ts +22 -0
- package/src/selectors/{querySelectorAll.js → querySelectorAll.ts} +7 -5
- package/src/strings/{DOMContentLoadedEvent.js → DOMContentLoadedEvent.ts} +0 -1
- package/src/strings/{DOMMouseScrollEvent.js → DOMMouseScrollEvent.ts} +0 -1
- package/src/strings/{abortEvent.js → abortEvent.ts} +0 -1
- package/src/strings/{addEventListener.js → addEventListener.ts} +0 -1
- package/src/strings/{animationDelay.js → animationDelay.ts} +0 -1
- package/src/strings/{animationDuration.js → animationDuration.ts} +0 -1
- package/src/strings/{animationEndEvent.js → animationEndEvent.ts} +0 -1
- package/src/strings/{animationName.js → animationName.ts} +0 -1
- package/src/strings/{ariaChecked.js → ariaChecked.ts} +0 -1
- package/src/strings/{ariaDescribedBy.js → ariaDescribedBy.ts} +0 -1
- package/src/strings/{ariaDescription.js → ariaDescription.ts} +0 -1
- package/src/strings/{ariaExpanded.js → ariaExpanded.ts} +0 -1
- package/src/strings/{ariaHasPopup.js → ariaHasPopup.ts} +0 -1
- package/src/strings/{ariaHidden.js → ariaHidden.ts} +0 -1
- package/src/strings/{ariaLabel.js → ariaLabel.ts} +0 -1
- package/src/strings/{ariaLabelledBy.js → ariaLabelledBy.ts} +0 -1
- package/src/strings/{ariaModal.js → ariaModal.ts} +0 -1
- package/src/strings/{ariaPressed.js → ariaPressed.ts} +0 -1
- package/src/strings/{ariaSelected.js → ariaSelected.ts} +0 -1
- package/src/strings/{ariaValueMax.js → ariaValueMax.ts} +0 -1
- package/src/strings/{ariaValueMin.js → ariaValueMin.ts} +0 -1
- package/src/strings/{ariaValueNow.js → ariaValueNow.ts} +0 -1
- package/src/strings/{ariaValueText.js → ariaValueText.ts} +0 -1
- package/src/strings/{beforeunloadEvent.js → beforeunloadEvent.ts} +0 -1
- package/src/strings/{bezierEasings.js → bezierEasings.ts} +0 -1
- package/src/strings/{blurEvent.js → blurEvent.ts} +0 -1
- package/src/strings/{changeEvent.js → changeEvent.ts} +0 -1
- package/src/strings/{contextmenuEvent.js → contextmenuEvent.ts} +0 -1
- package/src/strings/dragEvent.ts +5 -0
- package/src/strings/dragendEvent.ts +5 -0
- package/src/strings/dragenterEvent.ts +5 -0
- package/src/strings/dragleaveEvent.ts +5 -0
- package/src/strings/dragoverEvent.ts +5 -0
- package/src/strings/dragstartEvent.ts +5 -0
- package/src/strings/{errorEvent.js → errorEvent.ts} +0 -1
- package/src/strings/{focusEvent.js → focusEvent.ts} +0 -1
- package/src/strings/{focusEvents.js → focusEvents.ts} +0 -1
- package/src/strings/{focusinEvent.js → focusinEvent.ts} +0 -1
- package/src/strings/{focusoutEvent.js → focusoutEvent.ts} +0 -1
- package/src/strings/{gesturechangeEvent.js → gesturechangeEvent.ts} +0 -1
- package/src/strings/{gestureendEvent.js → gestureendEvent.ts} +0 -1
- package/src/strings/{gesturestartEvent.js → gesturestartEvent.ts} +0 -1
- package/src/strings/{keyAlt.js → keyAlt.ts} +1 -1
- package/src/strings/{keyArrowDown.js → keyArrowDown.ts} +1 -1
- package/src/strings/{keyArrowLeft.js → keyArrowLeft.ts} +1 -1
- package/src/strings/{keyArrowRight.js → keyArrowRight.ts} +1 -1
- package/src/strings/{keyArrowUp.js → keyArrowUp.ts} +1 -1
- package/src/strings/{keyBackspace.js → keyBackspace.ts} +1 -1
- package/src/strings/{keyCapsLock.js → keyCapsLock.ts} +1 -1
- package/src/strings/{keyControl.js → keyControl.ts} +1 -1
- package/src/strings/{keyDelete.js → keyDelete.ts} +1 -1
- package/src/strings/{keyEnter.js → keyEnter.ts} +1 -1
- package/src/strings/{keyEscape.js → keyEscape.ts} +1 -1
- package/src/strings/{keyInsert.js → keyInsert.ts} +1 -1
- package/src/strings/{keyMeta.js → keyMeta.ts} +1 -1
- package/src/strings/{keyPause.js → keyPause.ts} +1 -1
- package/src/strings/{keyScrollLock.js → keyScrollLock.ts} +1 -1
- package/src/strings/{keyShift.js → keyShift.ts} +1 -1
- package/src/strings/{keySpace.js → keySpace.ts} +1 -1
- package/src/strings/{keyTab.js → keyTab.ts} +1 -1
- package/src/strings/{keyboardEventKeys.js → keyboardEventKeys.ts} +0 -1
- package/src/strings/{keydownEvent.js → keydownEvent.ts} +0 -1
- package/src/strings/{keypressEvent.js → keypressEvent.ts} +0 -1
- package/src/strings/{keyupEvent.js → keyupEvent.ts} +0 -1
- package/src/strings/{loadEvent.js → loadEvent.ts} +0 -1
- package/src/strings/{loadstartEvent.js → loadstartEvent.ts} +0 -1
- package/src/strings/{mouseClickEvents.js → mouseClickEvents.ts} +0 -1
- package/src/strings/mouseHoverEvents.ts +8 -0
- package/src/strings/{mouseSwipeEvents.js → mouseSwipeEvents.ts} +4 -2
- package/src/strings/{mouseclickEvent.js → mouseclickEvent.ts} +0 -1
- package/src/strings/{mousedblclickEvent.js → mousedblclickEvent.ts} +0 -1
- package/src/strings/{mousedownEvent.js → mousedownEvent.ts} +0 -1
- package/src/strings/{mouseenterEvent.js → mouseenterEvent.ts} +0 -1
- package/src/strings/{mousehoverEvent.js → mousehoverEvent.ts} +0 -1
- package/src/strings/{mouseinEvent.js → mouseinEvent.ts} +0 -1
- package/src/strings/{mouseleaveEvent.js → mouseleaveEvent.ts} +0 -1
- package/src/strings/{mousemoveEvent.js → mousemoveEvent.ts} +0 -1
- package/src/strings/{mouseoutEvent.js → mouseoutEvent.ts} +0 -1
- package/src/strings/{mouseoverEvent.js → mouseoverEvent.ts} +0 -1
- package/src/strings/{mouseupEvent.js → mouseupEvent.ts} +0 -1
- package/src/strings/{mousewheelEvent.js → mousewheelEvent.ts} +0 -1
- package/src/strings/{moveEvent.js → moveEvent.ts} +0 -1
- package/src/strings/{nativeEvents.js → nativeEvents.ts} +0 -0
- package/src/strings/{offsetHeight.js → offsetHeight.ts} +0 -1
- package/src/strings/{offsetWidth.js → offsetWidth.ts} +0 -1
- package/src/strings/{orientationchangeEvent.js → orientationchangeEvent.ts} +0 -1
- package/src/strings/{pointercancelEvent.js → pointercancelEvent.ts} +0 -1
- package/src/strings/{pointerdownEvent.js → pointerdownEvent.ts} +0 -1
- package/src/strings/{pointerleaveEvent.js → pointerleaveEvent.ts} +0 -1
- package/src/strings/{pointermoveEvent.js → pointermoveEvent.ts} +0 -1
- package/src/strings/{pointerupEvent.js → pointerupEvent.ts} +0 -1
- package/src/strings/{readystatechangeEvent.js → readystatechangeEvent.ts} +0 -1
- package/src/strings/{removeEventListener.js → removeEventListener.ts} +0 -1
- package/src/strings/{resetEvent.js → resetEvent.ts} +0 -1
- package/src/strings/{resizeEvent.js → resizeEvent.ts} +0 -1
- package/src/strings/{scrollEvent.js → scrollEvent.ts} +0 -1
- package/src/strings/{scrollHeight.js → scrollHeight.ts} +0 -1
- package/src/strings/{scrollWidth.js → scrollWidth.ts} +0 -1
- package/src/strings/{selectEvent.js → selectEvent.ts} +0 -1
- package/src/strings/{selectendEvent.js → selectendEvent.ts} +0 -1
- package/src/strings/{selectstartEvent.js → selectstartEvent.ts} +0 -1
- package/src/strings/{submitEvent.js → submitEvent.ts} +0 -1
- package/src/strings/tabindex.ts +5 -0
- package/src/strings/touchEvents.ts +10 -0
- package/src/strings/{touchcancelEvent.js → touchcancelEvent.ts} +0 -1
- package/src/strings/{touchendEvent.js → touchendEvent.ts} +0 -1
- package/src/strings/{touchmoveEvent.js → touchmoveEvent.ts} +0 -1
- package/src/strings/{touchstartEvent.js → touchstartEvent.ts} +0 -1
- package/src/strings/{transitionDelay.js → transitionDelay.ts} +0 -1
- package/src/strings/{transitionDuration.js → transitionDuration.ts} +0 -1
- package/src/strings/{transitionEndEvent.js → transitionEndEvent.ts} +0 -1
- package/src/strings/{transitionProperty.js → transitionProperty.ts} +0 -2
- package/src/strings/{unloadEvent.js → unloadEvent.ts} +0 -1
- package/src/strings/{userAgent.js → userAgent.ts} +0 -0
- package/src/strings/userAgentData.ts +9 -0
- package/tsconfig.json +30 -0
- package/vite.config.ts +30 -0
- package/dist/shorty.esm.js +0 -2599
- package/dist/shorty.esm.min.js +0 -2
- package/dist/shorty.min.js +0 -2
- package/src/attr/getAttribute.js +0 -9
- package/src/attr/getAttributeNS.js +0 -10
- package/src/attr/hasAttribute.js +0 -9
- package/src/attr/hasAttributeNS.js +0 -10
- package/src/attr/removeAttribute.js +0 -9
- package/src/attr/removeAttributeNS.js +0 -10
- package/src/attr/setAttribute.js +0 -10
- package/src/attr/setAttributeNS.js +0 -11
- package/src/boolean/isApple.js +0 -13
- package/src/boolean/support3DTransform.js +0 -9
- package/src/boolean/supportAnimation.js +0 -9
- package/src/boolean/supportTouch.js +0 -7
- package/src/boolean/supportTransform.js +0 -9
- package/src/boolean/supportTransition.js +0 -9
- package/src/class/addClass.js +0 -10
- package/src/class/hasClass.js +0 -10
- package/src/class/removeClass.js +0 -10
- package/src/event/off.js +0 -9
- package/src/event/on.js +0 -9
- package/src/event/one.js +0 -23
- package/src/get/getDocumentBody.js +0 -10
- package/src/get/getDocumentElement.js +0 -11
- package/src/get/getDocumentHead.js +0 -10
- package/src/get/getElementAnimationDelayLegacy.js +0 -21
- package/src/get/getElementAnimationDurationLegacy.js +0 -21
- package/src/get/getElementStyle.js +0 -20
- package/src/get/getElementTransitionDelayLegacy.js +0 -21
- package/src/get/getElementTransitionDurationLegacy.js +0 -21
- package/src/get/getUID.js +0 -34
- package/src/is/isArray.js +0 -8
- package/src/is/isCustomElement.js +0 -8
- package/src/is/isDocument.js +0 -10
- package/src/is/isElementsArray.js +0 -12
- package/src/is/isFunction.js +0 -8
- package/src/is/isHTMLCollection.js +0 -8
- package/src/is/isHTMLElement.js +0 -9
- package/src/is/isHTMLImageElement.js +0 -8
- package/src/is/isMedia.js +0 -14
- package/src/is/isNode.js +0 -9
- package/src/is/isNodeList.js +0 -9
- package/src/is/isNumber.js +0 -8
- package/src/is/isObject.js +0 -8
- package/src/is/isRTL.js +0 -9
- package/src/is/isSVGElement.js +0 -11
- package/src/is/isShadowRoot.js +0 -9
- package/src/is/isString.js +0 -8
- package/src/is/isTableElement.js +0 -11
- package/src/is/isWindow.js +0 -9
- package/src/misc/ArrayFrom.js +0 -8
- package/src/misc/Float32ArrayFrom.js +0 -7
- package/src/misc/Float64ArrayFrom.js +0 -7
- package/src/misc/ObjectAssign.js +0 -7
- package/src/misc/ObjectEntries.js +0 -7
- package/src/misc/ObjectKeys.js +0 -7
- package/src/misc/ObjectValues.js +0 -7
- package/src/misc/OriginalEvent.js +0 -20
- package/src/misc/createElement.js +0 -27
- package/src/misc/createElementNS.js +0 -30
- package/src/misc/data.js +0 -78
- package/src/misc/dispatchEvent.js +0 -8
- package/src/misc/distinct.js +0 -10
- package/src/misc/emulateAnimationEndLegacy.js +0 -41
- package/src/misc/emulateTransitionEndLegacy.js +0 -41
- package/src/misc/focus.js +0 -7
- package/src/misc/normalizeOptions.js +0 -49
- package/src/misc/normalizeValue.js +0 -34
- package/src/misc/passiveHandlerLegacy.js +0 -10
- package/src/misc/reflow.js +0 -8
- package/src/misc/setElementStyle.js +0 -19
- package/src/misc/timer.js +0 -75
- package/src/misc/toLowerCase.js +0 -8
- package/src/misc/toUpperCase.js +0 -8
- package/src/misc/version.js +0 -8
- package/src/selectors/closest.js +0 -16
- package/src/selectors/getElementById.js +0 -14
- package/src/selectors/getElementsByClassName.js +0 -15
- package/src/selectors/getElementsByTagName.js +0 -15
- package/src/selectors/matches.js +0 -10
- package/src/selectors/matchesLegacy.js +0 -23
- package/src/selectors/querySelector.js +0 -19
- package/src/strings/animationDelayLegacy.js +0 -9
- package/src/strings/animationDurationLegacy.js +0 -9
- package/src/strings/animationEndEventLegacy.js +0 -9
- package/src/strings/animationNameLegacy.js +0 -9
- package/src/strings/mouseHoverEvents.js +0 -7
- package/src/strings/touchEvents.js +0 -8
- package/src/strings/transitionDelayLegacy.js +0 -9
- package/src/strings/transitionDurationLegacy.js +0 -9
- package/src/strings/transitionEndEventLegacy.js +0 -9
- package/src/strings/transitionPropertyLegacy.js +0 -12
- package/src/strings/userAgentData.js +0 -7
- package/types/index.d.ts +0 -257
- package/types/module/shorty.ts +0 -248
- package/types/shorty.d.ts +0 -2316
package/src/is/isNodeList.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Checks if an object is a `NodeList`.
|
|
3
|
-
* => equivalent to `object instanceof NodeList`
|
|
4
|
-
*
|
|
5
|
-
* @param {any} object the target object
|
|
6
|
-
* @returns {boolean} the query result
|
|
7
|
-
*/
|
|
8
|
-
const isNodeList = (object) => (object && object.constructor.name === 'NodeList') || false;
|
|
9
|
-
export default isNodeList;
|
package/src/is/isNumber.js
DELETED
package/src/is/isObject.js
DELETED
package/src/is/isRTL.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import getDocumentElement from '../get/getDocumentElement';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Checks if a page is Right To Left.
|
|
5
|
-
* @param {HTMLElement=} node the target
|
|
6
|
-
* @returns {boolean} the query result
|
|
7
|
-
*/
|
|
8
|
-
const isRTL = (node) => getDocumentElement(node).dir === 'rtl';
|
|
9
|
-
export default isRTL;
|
package/src/is/isSVGElement.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import getWindow from '../get/getWindow';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Check if an element is an `<svg>` or any other SVG element.
|
|
5
|
-
* @param {any} element the target element
|
|
6
|
-
* @returns {boolean} the query result
|
|
7
|
-
*/
|
|
8
|
-
const isSVGElement = (element) => (element && element instanceof getWindow(element).SVGElement)
|
|
9
|
-
|| false;
|
|
10
|
-
|
|
11
|
-
export default isSVGElement;
|
package/src/is/isShadowRoot.js
DELETED
package/src/is/isString.js
DELETED
package/src/is/isTableElement.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Check if a target element is a `<table>`, `<td>` or `<th>`.
|
|
3
|
-
* This specific check is important for determining
|
|
4
|
-
* the `offsetParent` of a given element.
|
|
5
|
-
*
|
|
6
|
-
* @param {any} element the target element
|
|
7
|
-
* @returns {boolean} the query result
|
|
8
|
-
*/
|
|
9
|
-
const isTableElement = (element) => (element && ['TABLE', 'TD', 'TH'].includes(element.tagName))
|
|
10
|
-
|| false;
|
|
11
|
-
export default isTableElement;
|
package/src/is/isWindow.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Check if a target object is `Window`.
|
|
3
|
-
* => equivalent to `object instanceof Window`
|
|
4
|
-
*
|
|
5
|
-
* @param {any} object the target object
|
|
6
|
-
* @returns {boolean} the query result
|
|
7
|
-
*/
|
|
8
|
-
const isWindow = (object) => (object && object.constructor.name === 'Window') || false;
|
|
9
|
-
export default isWindow;
|
package/src/misc/ArrayFrom.js
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Shortcut for `Float32Array.from()` static method.
|
|
3
|
-
* @param {any[] | HTMLCollection | NodeList} arr array-like iterable object
|
|
4
|
-
* @returns {Float32Array}
|
|
5
|
-
*/
|
|
6
|
-
const Float32ArrayFrom = (arr) => Float32Array.from(Array.from(arr));
|
|
7
|
-
export default Float32ArrayFrom;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Shortcut for `Float64Array.from()` static method.
|
|
3
|
-
* @param {any[] | HTMLCollection | NodeList} arr array-like iterable object
|
|
4
|
-
* @returns {Float64Array}
|
|
5
|
-
*/
|
|
6
|
-
const Float64ArrayFrom = (arr) => Float64Array.from(Array.from(arr));
|
|
7
|
-
export default Float64ArrayFrom;
|
package/src/misc/ObjectAssign.js
DELETED
package/src/misc/ObjectKeys.js
DELETED
package/src/misc/ObjectValues.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import isObject from '../is/isObject';
|
|
2
|
-
import ObjectAssign from './ObjectAssign';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Returns a namespaced `CustomEvent` specific to each component.
|
|
6
|
-
* @param {string} EventType Event.type
|
|
7
|
-
* @param {Record<string, any>=} config Event.options | Event.properties
|
|
8
|
-
* @returns {SHORTY.OriginalEvent} a new namespaced event
|
|
9
|
-
*/
|
|
10
|
-
export default function OriginalEvent(EventType, config) {
|
|
11
|
-
const OriginalCustomEvent = new CustomEvent(EventType, {
|
|
12
|
-
cancelable: true, bubbles: true,
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
/* istanbul ignore else */
|
|
16
|
-
if (isObject(config)) {
|
|
17
|
-
ObjectAssign(OriginalCustomEvent, config);
|
|
18
|
-
}
|
|
19
|
-
return OriginalCustomEvent;
|
|
20
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import getDocument from '../get/getDocument';
|
|
2
|
-
import ObjectAssign from './ObjectAssign';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* This is a shortie for `document.createElement` method
|
|
6
|
-
* which allows you to create a new `HTMLElement` for a given `tagName`
|
|
7
|
-
* or based on an object with specific non-readonly attributes:
|
|
8
|
-
* `id`, `className`, `textContent`, `style`, etc.
|
|
9
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/API/Document/createElement
|
|
10
|
-
*
|
|
11
|
-
* @param {Record<string, string> | string} param `tagName` or object
|
|
12
|
-
* @return {HTMLElement} a new `HTMLElement` or `Element`
|
|
13
|
-
*/
|
|
14
|
-
export default function createElement(param) {
|
|
15
|
-
if (!param) return null;
|
|
16
|
-
|
|
17
|
-
if (typeof param === 'string') {
|
|
18
|
-
return getDocument().createElement(param);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
const { tagName } = param;
|
|
22
|
-
const attr = { ...param };
|
|
23
|
-
const newElement = createElement(tagName);
|
|
24
|
-
delete attr.tagName;
|
|
25
|
-
ObjectAssign(newElement, attr);
|
|
26
|
-
return newElement;
|
|
27
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import getDocument from '../get/getDocument';
|
|
2
|
-
import ObjectEntries from './ObjectEntries';
|
|
3
|
-
import setAttribute from '../attr/setAttribute';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* This is a shortie for `document.createElementNS` method
|
|
7
|
-
* which allows you to create a new `HTMLElement` for a given `tagName`
|
|
8
|
-
* or based on an object with specific non-readonly attributes:
|
|
9
|
-
* `id`, `className`, `textContent`, `style`, etc.
|
|
10
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/API/Document/createElementNS
|
|
11
|
-
*
|
|
12
|
-
* @param {string} namespace `namespaceURI` to associate with the new `HTMLElement`
|
|
13
|
-
* @param {Record<string, string> | string} param `tagName` or object
|
|
14
|
-
* @return {HTMLElement} a new `HTMLElement` or `Element`
|
|
15
|
-
*/
|
|
16
|
-
export default function createElementNS(namespace, param) {
|
|
17
|
-
if (!namespace && !param) return null;
|
|
18
|
-
if (typeof param === 'string') {
|
|
19
|
-
return getDocument().createElementNS(namespace, param);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
const { tagName } = param;
|
|
23
|
-
const attr = { ...param };
|
|
24
|
-
const newElement = createElementNS(namespace, tagName);
|
|
25
|
-
delete attr.tagName;
|
|
26
|
-
ObjectEntries(attr).forEach(([key, value]) => {
|
|
27
|
-
setAttribute(newElement, key, value);
|
|
28
|
-
});
|
|
29
|
-
return newElement;
|
|
30
|
-
}
|
package/src/misc/data.js
DELETED
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import isHTMLElement from '../is/isHTMLElement';
|
|
2
|
-
|
|
3
|
-
/** @type {Map<string, Map<HTMLElement, Record<string, any>>>} */
|
|
4
|
-
const componentData = new Map();
|
|
5
|
-
/**
|
|
6
|
-
* An interface for web components background data.
|
|
7
|
-
* @see https://github.com/thednp/bootstrap.native/blob/master/src/components/base-component.js
|
|
8
|
-
*/
|
|
9
|
-
const Data = {
|
|
10
|
-
/**
|
|
11
|
-
* Sets web components data.
|
|
12
|
-
* @param {HTMLElement} element target element
|
|
13
|
-
* @param {string} component the component's name or a unique key
|
|
14
|
-
* @param {Record<string, any>} instance the component instance
|
|
15
|
-
*/
|
|
16
|
-
set: (element, component, instance) => {
|
|
17
|
-
if (!isHTMLElement(element)) return;
|
|
18
|
-
|
|
19
|
-
/* istanbul ignore else */
|
|
20
|
-
if (!componentData.has(component)) {
|
|
21
|
-
componentData.set(component, new Map());
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
const instanceMap = componentData.get(component);
|
|
25
|
-
// not undefined, but defined right above
|
|
26
|
-
instanceMap.set(element, instance);
|
|
27
|
-
},
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Returns all instances for specified component.
|
|
31
|
-
* @param {string} component the component's name or a unique key
|
|
32
|
-
* @returns {Map<HTMLElement, Record<string, any>>?} all the component instances
|
|
33
|
-
*/
|
|
34
|
-
getAllFor: (component) => {
|
|
35
|
-
const instanceMap = componentData.get(component);
|
|
36
|
-
|
|
37
|
-
return instanceMap || null;
|
|
38
|
-
},
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Returns the instance associated with the target.
|
|
42
|
-
* @param {HTMLElement} element target element
|
|
43
|
-
* @param {string} component the component's name or a unique key
|
|
44
|
-
* @returns {Record<string, any>?} the instance
|
|
45
|
-
*/
|
|
46
|
-
get: (element, component) => {
|
|
47
|
-
if (!isHTMLElement(element) || !component) return null;
|
|
48
|
-
const allForC = Data.getAllFor(component);
|
|
49
|
-
const instance = element && allForC && allForC.get(element);
|
|
50
|
-
|
|
51
|
-
return instance || null;
|
|
52
|
-
},
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* Removes web components data.
|
|
56
|
-
* @param {HTMLElement} element target element
|
|
57
|
-
* @param {string} component the component's name or a unique key
|
|
58
|
-
*/
|
|
59
|
-
remove: (element, component) => {
|
|
60
|
-
const instanceMap = componentData.get(component);
|
|
61
|
-
if (!instanceMap || !isHTMLElement(element)) return;
|
|
62
|
-
|
|
63
|
-
instanceMap.delete(element);
|
|
64
|
-
|
|
65
|
-
/* istanbul ignore else */
|
|
66
|
-
if (instanceMap.size === 0) {
|
|
67
|
-
componentData.delete(component);
|
|
68
|
-
}
|
|
69
|
-
},
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* An alias for `Data.get()`.
|
|
74
|
-
* @type {SHORTY.getInstance<any>}
|
|
75
|
-
*/
|
|
76
|
-
export const getInstance = (target, component) => Data.get(target, component);
|
|
77
|
-
|
|
78
|
-
export default Data;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Shortcut for the `Element.dispatchEvent(Event)` method.
|
|
3
|
-
*
|
|
4
|
-
* @param {HTMLElement} element is the target
|
|
5
|
-
* @param {Event} event is the `Event` object
|
|
6
|
-
*/
|
|
7
|
-
const dispatchEvent = (element, event) => element.dispatchEvent(event);
|
|
8
|
-
export default dispatchEvent;
|
package/src/misc/distinct.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* JavaScript `Array` distinct.
|
|
3
|
-
* @see https://codeburst.io/javascript-array-distinct-5edc93501dc4
|
|
4
|
-
* @param {any} value
|
|
5
|
-
* @param {number} index
|
|
6
|
-
* @param {any} self
|
|
7
|
-
* @returns {boolean}
|
|
8
|
-
*/
|
|
9
|
-
const distinct = (value, index, self) => self.indexOf(value) === index;
|
|
10
|
-
export default distinct;
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import supportAnimation from '../boolean/supportAnimation';
|
|
2
|
-
import animationEndEventLegacy from '../strings/animationEndEventLegacy';
|
|
3
|
-
import getElementAnimationDelay from '../get/getElementAnimationDelayLegacy';
|
|
4
|
-
import getElementAnimationDuration from '../get/getElementAnimationDurationLegacy';
|
|
5
|
-
import dispatchEvent from './dispatchEvent';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Utility to make sure callbacks are consistently
|
|
9
|
-
* called when animation ends.
|
|
10
|
-
*
|
|
11
|
-
* @param {HTMLElement} element target
|
|
12
|
-
* @param {EventListener} handler `animationend` callback
|
|
13
|
-
*/
|
|
14
|
-
export default function emulateAnimationEnd(element, handler) {
|
|
15
|
-
let called = 0;
|
|
16
|
-
const endEvent = new Event(animationEndEventLegacy);
|
|
17
|
-
const duration = getElementAnimationDuration(element);
|
|
18
|
-
const delay = getElementAnimationDelay(element);
|
|
19
|
-
|
|
20
|
-
if (supportAnimation && duration) {
|
|
21
|
-
/**
|
|
22
|
-
* Wrap the handler in on -> off callback
|
|
23
|
-
* @param {Event} e Event object
|
|
24
|
-
*/
|
|
25
|
-
const animationEndWrapper = (e) => {
|
|
26
|
-
/* istanbul ignore else */
|
|
27
|
-
if (e.target === element) {
|
|
28
|
-
handler.apply(element, [e]);
|
|
29
|
-
element.removeEventListener(animationEndEventLegacy, animationEndWrapper);
|
|
30
|
-
called = 1;
|
|
31
|
-
}
|
|
32
|
-
};
|
|
33
|
-
element.addEventListener(animationEndEventLegacy, animationEndWrapper);
|
|
34
|
-
setTimeout(() => {
|
|
35
|
-
/* istanbul ignore next */
|
|
36
|
-
if (!called) dispatchEvent(element, endEvent);
|
|
37
|
-
}, duration + delay + 17);
|
|
38
|
-
} else {
|
|
39
|
-
handler.apply(element, [endEvent]);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import supportTransition from '../boolean/supportTransition';
|
|
2
|
-
import transitionEndEventLegacy from '../strings/transitionEndEventLegacy';
|
|
3
|
-
import getElementTransitionDelay from '../get/getElementTransitionDelayLegacy';
|
|
4
|
-
import getElementTransitionDuration from '../get/getElementTransitionDurationLegacy';
|
|
5
|
-
import dispatchEvent from './dispatchEvent';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Utility to make sure callbacks are consistently
|
|
9
|
-
* called when transition ends.
|
|
10
|
-
*
|
|
11
|
-
* @param {HTMLElement} element target
|
|
12
|
-
* @param {EventListener} handler `transitionend` callback
|
|
13
|
-
*/
|
|
14
|
-
export default function emulateTransitionEnd(element, handler) {
|
|
15
|
-
let called = 0;
|
|
16
|
-
const endEvent = new Event(transitionEndEventLegacy);
|
|
17
|
-
const duration = getElementTransitionDuration(element);
|
|
18
|
-
const delay = getElementTransitionDelay(element);
|
|
19
|
-
|
|
20
|
-
if (supportTransition && duration) {
|
|
21
|
-
/**
|
|
22
|
-
* Wrap the handler in on -> off callback
|
|
23
|
-
* @param {Event} e Event object
|
|
24
|
-
*/
|
|
25
|
-
const transitionEndWrapper = (e) => {
|
|
26
|
-
/* istanbul ignore else */
|
|
27
|
-
if (e.target === element) {
|
|
28
|
-
handler.apply(element, [e]);
|
|
29
|
-
element.removeEventListener(transitionEndEventLegacy, transitionEndWrapper);
|
|
30
|
-
called = 1;
|
|
31
|
-
}
|
|
32
|
-
};
|
|
33
|
-
element.addEventListener(transitionEndEventLegacy, transitionEndWrapper);
|
|
34
|
-
setTimeout(() => {
|
|
35
|
-
/* istanbul ignore next */
|
|
36
|
-
if (!called) dispatchEvent(element, endEvent);
|
|
37
|
-
}, duration + delay + 17);
|
|
38
|
-
} else {
|
|
39
|
-
handler.apply(element, [endEvent]);
|
|
40
|
-
}
|
|
41
|
-
}
|
package/src/misc/focus.js
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import getAttribute from '../attr/getAttribute';
|
|
2
|
-
import normalizeValue from './normalizeValue';
|
|
3
|
-
import ObjectKeys from './ObjectKeys';
|
|
4
|
-
import toLowerCase from './toLowerCase';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Utility to normalize component options.
|
|
8
|
-
*
|
|
9
|
-
* @param {HTMLElement} element target
|
|
10
|
-
* @param {Record<string, any>} defaultOps component default options
|
|
11
|
-
* @param {Record<string, any>} inputOps component instance options
|
|
12
|
-
* @param {string=} ns component namespace
|
|
13
|
-
* @return {Record<string, any>} normalized component options object
|
|
14
|
-
*/
|
|
15
|
-
export default function normalizeOptions(element, defaultOps, inputOps, ns) {
|
|
16
|
-
const data = { ...element.dataset };
|
|
17
|
-
/** @type {Record<string, any>} */
|
|
18
|
-
const normalOps = {};
|
|
19
|
-
/** @type {Record<string, any>} */
|
|
20
|
-
const dataOps = {};
|
|
21
|
-
const title = 'title';
|
|
22
|
-
|
|
23
|
-
ObjectKeys(data).forEach((k) => {
|
|
24
|
-
const key = ns && k.includes(ns)
|
|
25
|
-
? k.replace(ns, '').replace(/[A-Z]/, (match) => toLowerCase(match))
|
|
26
|
-
: k;
|
|
27
|
-
|
|
28
|
-
dataOps[key] = normalizeValue(data[k]);
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
ObjectKeys(inputOps).forEach((k) => {
|
|
32
|
-
inputOps[k] = normalizeValue(inputOps[k]);
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
ObjectKeys(defaultOps).forEach((k) => {
|
|
36
|
-
/* istanbul ignore else */
|
|
37
|
-
if (k in inputOps) {
|
|
38
|
-
normalOps[k] = inputOps[k];
|
|
39
|
-
} else if (k in dataOps) {
|
|
40
|
-
normalOps[k] = dataOps[k];
|
|
41
|
-
} else {
|
|
42
|
-
normalOps[k] = k === title
|
|
43
|
-
? getAttribute(element, title)
|
|
44
|
-
: defaultOps[k];
|
|
45
|
-
}
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
return normalOps;
|
|
49
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The raw value or a given component option.
|
|
3
|
-
*
|
|
4
|
-
* @typedef {string | HTMLElement | Function | number | boolean | null} niceValue
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Utility to normalize component options
|
|
9
|
-
*
|
|
10
|
-
* @param {any} value the input value
|
|
11
|
-
* @return {niceValue} the normalized value
|
|
12
|
-
*/
|
|
13
|
-
export default function normalizeValue(value) {
|
|
14
|
-
if (['true', true].includes(value)) { // boolean
|
|
15
|
-
// if ('true' === value) { // boolean
|
|
16
|
-
return true;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
if (['false', false].includes(value)) { // boolean
|
|
20
|
-
// if ('false' === value) { // boolean
|
|
21
|
-
return false;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
if (value === '' || value === 'null') { // null
|
|
25
|
-
return null;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
if (value !== '' && !Number.isNaN(+value)) { // number
|
|
29
|
-
return +value;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
// string / function / HTMLElement / object
|
|
33
|
-
return value;
|
|
34
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import supportPassive from '../boolean/supportPassive';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* A global namespace for most scroll event listeners in legacy browsers.
|
|
5
|
-
* @type {Partial<AddEventListenerOptions> | boolean}
|
|
6
|
-
*/
|
|
7
|
-
const passiveHandler = supportPassive ? { passive: true }
|
|
8
|
-
: /* istanbul ignore next */false;
|
|
9
|
-
|
|
10
|
-
export default passiveHandler;
|
package/src/misc/reflow.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import ObjectAssign from './ObjectAssign';
|
|
2
|
-
import ObjectEntries from './ObjectEntries';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Shortcut for multiple uses of `HTMLElement.style.propertyName` method.
|
|
6
|
-
* @param {HTMLElement} element target element
|
|
7
|
-
* @param {Partial<CSSStyleDeclaration>} styles attribute value
|
|
8
|
-
*/
|
|
9
|
-
const setElementStyle = (element, styles) => {
|
|
10
|
-
ObjectEntries(styles).forEach(([key, value]) => {
|
|
11
|
-
if (key.includes('--')) {
|
|
12
|
-
element.style.setProperty(key, value);
|
|
13
|
-
} else {
|
|
14
|
-
const propObject = {}; propObject[key] = value;
|
|
15
|
-
ObjectAssign(element.style, propObject);
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
};
|
|
19
|
-
export default setElementStyle;
|
package/src/misc/timer.js
DELETED
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import isHTMLElement from '../is/isHTMLElement';
|
|
2
|
-
|
|
3
|
-
/** @type {Map<HTMLElement, any>} */
|
|
4
|
-
const TimeCache = new Map();
|
|
5
|
-
/**
|
|
6
|
-
* An interface for one or more `TimerHandler`s per `Element`.
|
|
7
|
-
* @see https://github.com/thednp/navbar.js/
|
|
8
|
-
*/
|
|
9
|
-
const Timer = {
|
|
10
|
-
/**
|
|
11
|
-
* Sets a new timeout timer for an element, or element -> key association.
|
|
12
|
-
* @param {HTMLElement} element target element
|
|
13
|
-
* @param {ReturnType<TimerHandler>} callback the callback
|
|
14
|
-
* @param {number} delay the execution delay
|
|
15
|
-
* @param {string=} key a unique key
|
|
16
|
-
*/
|
|
17
|
-
set: (element, callback, delay, key) => {
|
|
18
|
-
if (!isHTMLElement(element)) return;
|
|
19
|
-
|
|
20
|
-
/* istanbul ignore else */
|
|
21
|
-
if (key && key.length) {
|
|
22
|
-
/* istanbul ignore else */
|
|
23
|
-
if (!TimeCache.has(element)) {
|
|
24
|
-
TimeCache.set(element, new Map());
|
|
25
|
-
}
|
|
26
|
-
const keyTimers = TimeCache.get(element);
|
|
27
|
-
keyTimers.set(key, setTimeout(callback, delay));
|
|
28
|
-
} else {
|
|
29
|
-
TimeCache.set(element, setTimeout(callback, delay));
|
|
30
|
-
}
|
|
31
|
-
},
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Returns the timer associated with the target.
|
|
35
|
-
* @param {HTMLElement} element target element
|
|
36
|
-
* @param {string=} key a unique
|
|
37
|
-
* @returns {number?} the timer
|
|
38
|
-
*/
|
|
39
|
-
get: (element, key) => {
|
|
40
|
-
if (!isHTMLElement(element)) return null;
|
|
41
|
-
const keyTimers = TimeCache.get(element);
|
|
42
|
-
|
|
43
|
-
if (key && key.length && keyTimers && keyTimers.get) {
|
|
44
|
-
return keyTimers.get(key) || /* istanbul ignore next */null;
|
|
45
|
-
}
|
|
46
|
-
return keyTimers || null;
|
|
47
|
-
},
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* Clears the element's timer.
|
|
51
|
-
* @param {HTMLElement} element target element
|
|
52
|
-
* @param {string=} key a unique key
|
|
53
|
-
*/
|
|
54
|
-
clear: (element, key) => {
|
|
55
|
-
if (!isHTMLElement(element)) return;
|
|
56
|
-
|
|
57
|
-
if (key && key.length) {
|
|
58
|
-
const keyTimers = TimeCache.get(element);
|
|
59
|
-
/* istanbul ignore else */
|
|
60
|
-
if (keyTimers && keyTimers.get) {
|
|
61
|
-
clearTimeout(keyTimers.get(key));
|
|
62
|
-
keyTimers.delete(key);
|
|
63
|
-
/* istanbul ignore else */
|
|
64
|
-
if (keyTimers.size === 0) {
|
|
65
|
-
TimeCache.delete(element);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
} else {
|
|
69
|
-
clearTimeout(TimeCache.get(element));
|
|
70
|
-
TimeCache.delete(element);
|
|
71
|
-
}
|
|
72
|
-
},
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
export default Timer;
|
package/src/misc/toLowerCase.js
DELETED
package/src/misc/toUpperCase.js
DELETED