@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
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
/** @typedef {import('../types/index')} */
|
|
2
|
-
|
|
3
1
|
// strings
|
|
4
2
|
import ariaChecked from './strings/ariaChecked';
|
|
5
3
|
import ariaDescription from './strings/ariaDescription';
|
|
@@ -22,6 +20,12 @@ import abortEvent from './strings/abortEvent';
|
|
|
22
20
|
import blurEvent from './strings/blurEvent';
|
|
23
21
|
import moveEvent from './strings/moveEvent';
|
|
24
22
|
import changeEvent from './strings/changeEvent';
|
|
23
|
+
import dragEvent from './strings/dragEvent';
|
|
24
|
+
import dragstartEvent from './strings/dragstartEvent';
|
|
25
|
+
import dragenterEvent from './strings/dragenterEvent';
|
|
26
|
+
import dragleaveEvent from './strings/dragleaveEvent';
|
|
27
|
+
import dragoverEvent from './strings/dragoverEvent';
|
|
28
|
+
import dragendEvent from './strings/dragendEvent';
|
|
25
29
|
import errorEvent from './strings/errorEvent';
|
|
26
30
|
import resetEvent from './strings/resetEvent';
|
|
27
31
|
import resizeEvent from './strings/resizeEvent';
|
|
@@ -102,21 +106,13 @@ import keySpace from './strings/keySpace';
|
|
|
102
106
|
import keyTab from './strings/keyTab';
|
|
103
107
|
|
|
104
108
|
import animationDuration from './strings/animationDuration';
|
|
105
|
-
import animationDurationLegacy from './strings/animationDurationLegacy';
|
|
106
109
|
import animationDelay from './strings/animationDelay';
|
|
107
|
-
import animationDelayLegacy from './strings/animationDelayLegacy';
|
|
108
110
|
import animationName from './strings/animationName';
|
|
109
|
-
import animationNameLegacy from './strings/animationNameLegacy';
|
|
110
111
|
import animationEndEvent from './strings/animationEndEvent';
|
|
111
|
-
import animationEndEventLegacy from './strings/animationEndEventLegacy';
|
|
112
112
|
import transitionDuration from './strings/transitionDuration';
|
|
113
|
-
import transitionDurationLegacy from './strings/transitionDurationLegacy';
|
|
114
113
|
import transitionDelay from './strings/transitionDelay';
|
|
115
|
-
import transitionDelayLegacy from './strings/transitionDelayLegacy';
|
|
116
114
|
import transitionEndEvent from './strings/transitionEndEvent';
|
|
117
|
-
import transitionEndEventLegacy from './strings/transitionEndEventLegacy';
|
|
118
115
|
import transitionProperty from './strings/transitionProperty';
|
|
119
|
-
import transitionPropertyLegacy from './strings/transitionPropertyLegacy';
|
|
120
116
|
|
|
121
117
|
import addEventListener from './strings/addEventListener';
|
|
122
118
|
import removeEventListener from './strings/removeEventListener';
|
|
@@ -127,6 +123,7 @@ import offsetHeight from './strings/offsetHeight';
|
|
|
127
123
|
import offsetWidth from './strings/offsetWidth';
|
|
128
124
|
import scrollHeight from './strings/scrollHeight';
|
|
129
125
|
import scrollWidth from './strings/scrollWidth';
|
|
126
|
+
import tabindex from './strings/tabindex';
|
|
130
127
|
|
|
131
128
|
import userAgentData from './strings/userAgentData';
|
|
132
129
|
import userAgent from './strings/userAgent';
|
|
@@ -162,17 +159,21 @@ import on from './event/on';
|
|
|
162
159
|
import off from './event/off';
|
|
163
160
|
import one from './event/one';
|
|
164
161
|
|
|
162
|
+
// blocks
|
|
163
|
+
import documentBody from './blocks/documentBody';
|
|
164
|
+
import documentElement from './blocks/documentElement';
|
|
165
|
+
import documentHead from './blocks/documentHead';
|
|
166
|
+
|
|
165
167
|
// misc
|
|
166
168
|
import ArrayFrom from './misc/ArrayFrom';
|
|
167
|
-
import Data
|
|
169
|
+
import Data from './misc/data';
|
|
170
|
+
import getInstance from './misc/getInstance';
|
|
168
171
|
import createElement from './misc/createElement';
|
|
169
172
|
import createElementNS from './misc/createElementNS';
|
|
170
173
|
import dispatchEvent from './misc/dispatchEvent';
|
|
171
174
|
import distinct from './misc/distinct';
|
|
172
175
|
import emulateAnimationEnd from './misc/emulateAnimationEnd';
|
|
173
|
-
import emulateAnimationEndLegacy from './misc/emulateAnimationEndLegacy';
|
|
174
176
|
import emulateTransitionEnd from './misc/emulateTransitionEnd';
|
|
175
|
-
import emulateTransitionEndLegacy from './misc/emulateTransitionEndLegacy';
|
|
176
177
|
import Float32ArrayFrom from './misc/Float32ArrayFrom';
|
|
177
178
|
import Float64ArrayFrom from './misc/Float64ArrayFrom';
|
|
178
179
|
import focus from './misc/focus';
|
|
@@ -181,11 +182,11 @@ import normalizeOptions from './misc/normalizeOptions';
|
|
|
181
182
|
import normalizeValue from './misc/normalizeValue';
|
|
182
183
|
import ObjectAssign from './misc/ObjectAssign';
|
|
183
184
|
import ObjectEntries from './misc/ObjectEntries';
|
|
185
|
+
import ObjectHasOwn from './misc/ObjectHasOwn';
|
|
184
186
|
import ObjectKeys from './misc/ObjectKeys';
|
|
185
187
|
import ObjectValues from './misc/ObjectValues';
|
|
186
|
-
import
|
|
188
|
+
import createCustomEvent from './misc/createCustomEvent';
|
|
187
189
|
import passiveHandler from './misc/passiveHandler';
|
|
188
|
-
import passiveHandlerLegacy from './misc/passiveHandlerLegacy';
|
|
189
190
|
import reflow from './misc/reflow';
|
|
190
191
|
import setElementStyle from './misc/setElementStyle';
|
|
191
192
|
import Timer from './misc/timer';
|
|
@@ -199,14 +200,10 @@ import getDocumentBody from './get/getDocumentBody';
|
|
|
199
200
|
import getDocumentElement from './get/getDocumentElement';
|
|
200
201
|
import getDocumentHead from './get/getDocumentHead';
|
|
201
202
|
import getElementAnimationDuration from './get/getElementAnimationDuration';
|
|
202
|
-
import getElementAnimationDurationLegacy from './get/getElementAnimationDurationLegacy';
|
|
203
|
-
import getElementAnimationDelayLegacy from './get/getElementAnimationDelayLegacy';
|
|
204
203
|
import getElementAnimationDelay from './get/getElementAnimationDelay';
|
|
205
204
|
import getElementStyle from './get/getElementStyle';
|
|
206
205
|
import getElementTransitionDuration from './get/getElementTransitionDuration';
|
|
207
|
-
import getElementTransitionDurationLegacy from './get/getElementTransitionDurationLegacy';
|
|
208
206
|
import getElementTransitionDelay from './get/getElementTransitionDelay';
|
|
209
|
-
import getElementTransitionDelayLegacy from './get/getElementTransitionDelayLegacy';
|
|
210
207
|
import getNodeScroll from './get/getNodeScroll';
|
|
211
208
|
import getParentNode from './get/getParentNode';
|
|
212
209
|
import getRectRelativeToOffsetParent from './get/getRectRelativeToOffsetParent';
|
|
@@ -215,6 +212,7 @@ import getWindow from './get/getWindow';
|
|
|
215
212
|
|
|
216
213
|
// is
|
|
217
214
|
import isArray from './is/isArray';
|
|
215
|
+
import isCanvas from './is/isCanvas';
|
|
218
216
|
import isDocument from './is/isDocument';
|
|
219
217
|
import isCustomElement from './is/isCustomElement';
|
|
220
218
|
import isElement from './is/isElement';
|
|
@@ -226,6 +224,9 @@ import isObject from './is/isObject';
|
|
|
226
224
|
import isHTMLCollection from './is/isHTMLCollection';
|
|
227
225
|
import isHTMLElement from './is/isHTMLElement';
|
|
228
226
|
import isHTMLImageElement from './is/isHTMLImageElement';
|
|
227
|
+
import isJSON from './is/isJSON';
|
|
228
|
+
import isMap from './is/isMap';
|
|
229
|
+
import isWeakMap from './is/isWeakMap';
|
|
229
230
|
import isMedia from './is/isMedia';
|
|
230
231
|
import isNode from './is/isNode';
|
|
231
232
|
import isNodeList from './is/isNodeList';
|
|
@@ -247,11 +248,8 @@ import querySelectorAll from './selectors/querySelectorAll';
|
|
|
247
248
|
import getElementsByTagName from './selectors/getElementsByTagName';
|
|
248
249
|
import getElementsByClassName from './selectors/getElementsByClassName';
|
|
249
250
|
import matches from './selectors/matches';
|
|
250
|
-
import matchesLegacy from './selectors/matchesLegacy';
|
|
251
251
|
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
const SHORTY = {
|
|
252
|
+
export {
|
|
255
253
|
ariaChecked,
|
|
256
254
|
ariaDescription,
|
|
257
255
|
ariaDescribedBy,
|
|
@@ -272,6 +270,12 @@ const SHORTY = {
|
|
|
272
270
|
blurEvent,
|
|
273
271
|
moveEvent,
|
|
274
272
|
changeEvent,
|
|
273
|
+
dragEvent,
|
|
274
|
+
dragstartEvent,
|
|
275
|
+
dragenterEvent,
|
|
276
|
+
dragoverEvent,
|
|
277
|
+
dragleaveEvent,
|
|
278
|
+
dragendEvent,
|
|
275
279
|
errorEvent,
|
|
276
280
|
resetEvent,
|
|
277
281
|
resizeEvent,
|
|
@@ -323,21 +327,13 @@ const SHORTY = {
|
|
|
323
327
|
gesturestartEvent,
|
|
324
328
|
bezierEasings,
|
|
325
329
|
animationDuration,
|
|
326
|
-
animationDurationLegacy,
|
|
327
330
|
animationDelay,
|
|
328
|
-
animationDelayLegacy,
|
|
329
331
|
animationName,
|
|
330
|
-
animationNameLegacy,
|
|
331
332
|
animationEndEvent,
|
|
332
|
-
animationEndEventLegacy,
|
|
333
333
|
transitionDuration,
|
|
334
|
-
transitionDurationLegacy,
|
|
335
334
|
transitionDelay,
|
|
336
|
-
transitionDelayLegacy,
|
|
337
335
|
transitionEndEvent,
|
|
338
|
-
transitionEndEventLegacy,
|
|
339
336
|
transitionProperty,
|
|
340
|
-
transitionPropertyLegacy,
|
|
341
337
|
isMobile,
|
|
342
338
|
isApple,
|
|
343
339
|
isFirefox,
|
|
@@ -377,45 +373,47 @@ const SHORTY = {
|
|
|
377
373
|
scrollWidth,
|
|
378
374
|
userAgentData,
|
|
379
375
|
userAgent,
|
|
376
|
+
tabindex,
|
|
380
377
|
addClass,
|
|
381
378
|
removeClass,
|
|
382
379
|
hasClass,
|
|
383
380
|
on,
|
|
384
381
|
off,
|
|
385
382
|
one,
|
|
383
|
+
documentBody,
|
|
384
|
+
documentElement,
|
|
385
|
+
documentHead,
|
|
386
386
|
dispatchEvent,
|
|
387
387
|
distinct,
|
|
388
388
|
Data,
|
|
389
389
|
getInstance,
|
|
390
390
|
createElement,
|
|
391
391
|
createElementNS,
|
|
392
|
+
createCustomEvent,
|
|
392
393
|
toUpperCase,
|
|
393
394
|
toLowerCase,
|
|
394
395
|
Timer,
|
|
395
396
|
emulateAnimationEnd,
|
|
396
|
-
emulateAnimationEndLegacy,
|
|
397
397
|
emulateTransitionEnd,
|
|
398
|
-
emulateTransitionEndLegacy,
|
|
399
398
|
isElementInScrollRange,
|
|
400
399
|
isElementInViewport,
|
|
401
400
|
passiveHandler,
|
|
402
|
-
passiveHandlerLegacy,
|
|
403
401
|
getElementAnimationDuration,
|
|
404
|
-
getElementAnimationDurationLegacy,
|
|
405
402
|
getElementAnimationDelay,
|
|
406
|
-
getElementAnimationDelayLegacy,
|
|
407
403
|
getElementTransitionDuration,
|
|
408
|
-
getElementTransitionDurationLegacy,
|
|
409
404
|
getElementTransitionDelay,
|
|
410
|
-
getElementTransitionDelayLegacy,
|
|
411
405
|
getNodeScroll,
|
|
412
406
|
getParentNode,
|
|
413
407
|
getRectRelativeToOffsetParent,
|
|
414
408
|
getWindow,
|
|
415
409
|
isArray,
|
|
410
|
+
isCanvas,
|
|
416
411
|
isString,
|
|
417
412
|
isCustomElement,
|
|
418
413
|
isElement,
|
|
414
|
+
isJSON,
|
|
415
|
+
isMap,
|
|
416
|
+
isWeakMap,
|
|
419
417
|
isNode,
|
|
420
418
|
isNumber,
|
|
421
419
|
isHTMLElement,
|
|
@@ -441,7 +439,6 @@ const SHORTY = {
|
|
|
441
439
|
getElementsByClassName,
|
|
442
440
|
getElementsByTagName,
|
|
443
441
|
matches,
|
|
444
|
-
matchesLegacy,
|
|
445
442
|
normalizeValue,
|
|
446
443
|
normalizeOptions,
|
|
447
444
|
reflow,
|
|
@@ -451,11 +448,11 @@ const SHORTY = {
|
|
|
451
448
|
ArrayFrom,
|
|
452
449
|
Float32ArrayFrom,
|
|
453
450
|
Float64ArrayFrom,
|
|
451
|
+
ObjectHasOwn,
|
|
454
452
|
ObjectAssign,
|
|
455
453
|
ObjectEntries,
|
|
456
454
|
ObjectKeys,
|
|
457
455
|
ObjectValues,
|
|
458
|
-
OriginalEvent,
|
|
459
456
|
getBoundingClientRect,
|
|
460
457
|
getDocument,
|
|
461
458
|
getDocumentBody,
|
|
@@ -471,7 +468,4 @@ const SHORTY = {
|
|
|
471
468
|
setAttributeNS,
|
|
472
469
|
removeAttribute,
|
|
473
470
|
removeAttributeNS,
|
|
474
|
-
Version,
|
|
475
471
|
};
|
|
476
|
-
|
|
477
|
-
export default SHORTY;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// https://github.com/lukewarlow/user-agent-data-types/blob/master/index.d.ts
|
|
2
|
+
export declare interface NavigatorUABrand {
|
|
3
|
+
readonly brand: string;
|
|
4
|
+
readonly version: string;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export declare interface NavigatorUAData {
|
|
8
|
+
readonly brands: NavigatorUABrand[];
|
|
9
|
+
readonly mobile: boolean;
|
|
10
|
+
readonly platform: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export declare interface NavigatorUA extends Navigator {
|
|
14
|
+
readonly userAgentData: NavigatorUAData;
|
|
15
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import isNode from './isNode';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Checks if an element is an `HTMLCanvasElement` or `<canvas>`.
|
|
5
|
+
*
|
|
6
|
+
* @param element the target element
|
|
7
|
+
* @returns the query result
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
const isCanvas = (element?: unknown): element is HTMLCanvasElement =>
|
|
11
|
+
(isNode(element) && element.nodeName === 'CANVAS') || false;
|
|
12
|
+
|
|
13
|
+
export default isCanvas;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import isHTMLElement from './isHTMLElement';
|
|
2
|
+
import type { CustomElement } from '../interface/customElement';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Checks if an object is a `CustomElement`.
|
|
6
|
+
*
|
|
7
|
+
* @param element the target object
|
|
8
|
+
* @returns the query result
|
|
9
|
+
*/
|
|
10
|
+
const isCustomElement = <T extends CustomElement>(element?: unknown): element is T =>
|
|
11
|
+
(isHTMLElement(element) && !!(element as T).shadowRoot) || false;
|
|
12
|
+
|
|
13
|
+
export default isCustomElement;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import isNode from './isNode';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Checks if an object is a `Document`.
|
|
5
|
+
*
|
|
6
|
+
* @see https://dom.spec.whatwg.org/#node
|
|
7
|
+
*
|
|
8
|
+
* @param obj the target object
|
|
9
|
+
* @returns the query result
|
|
10
|
+
*/
|
|
11
|
+
const isDocument = (obj?: unknown): obj is Document => (isNode(obj) && obj.nodeType === 9) || false;
|
|
12
|
+
|
|
13
|
+
export default isDocument;
|
|
@@ -1,6 +1,11 @@
|
|
|
1
|
+
import isNode from './isNode';
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* Checks if an object is an `Element`.
|
|
5
|
+
*
|
|
3
6
|
* @see https://dom.spec.whatwg.org/#node
|
|
7
|
+
*
|
|
8
|
+
* ```
|
|
4
9
|
* ELEMENT_NODE = 1;
|
|
5
10
|
* ATTRIBUTE_NODE = 2;
|
|
6
11
|
* TEXT_NODE = 3;
|
|
@@ -12,11 +17,11 @@
|
|
|
12
17
|
* DOCUMENT_NODE = 9;
|
|
13
18
|
* DOCUMENT_TYPE_NODE = 10;
|
|
14
19
|
* DOCUMENT_FRAGMENT_NODE = 11;
|
|
15
|
-
*
|
|
16
|
-
* @param
|
|
17
|
-
* @returns
|
|
20
|
+
* ```
|
|
21
|
+
* @param element the target object
|
|
22
|
+
* @returns the query result
|
|
18
23
|
*/
|
|
19
|
-
const isElement = (element)
|
|
20
|
-
.some(
|
|
24
|
+
const isElement = (element?: unknown): element is Element =>
|
|
25
|
+
(isNode(element) && [1, 2, 3, 4, 5, 6, 7, 8].some(x => element.nodeType === x)) || false;
|
|
21
26
|
|
|
22
27
|
export default isElement;
|
|
@@ -6,11 +6,11 @@ import isNode from './isNode';
|
|
|
6
6
|
* Utility to determine if an `HTMLElement`
|
|
7
7
|
* is partially visible in viewport.
|
|
8
8
|
*
|
|
9
|
-
* @param
|
|
10
|
-
* @return
|
|
9
|
+
* @param element target
|
|
10
|
+
* @return the query result
|
|
11
11
|
*/
|
|
12
|
-
const isElementInScrollRange = (element) => {
|
|
13
|
-
if (!
|
|
12
|
+
const isElementInScrollRange = (element?: HTMLElement): boolean => {
|
|
13
|
+
if (!isNode(element)) return false;
|
|
14
14
|
|
|
15
15
|
const { top, bottom } = getBoundingClientRect(element);
|
|
16
16
|
const { clientHeight } = getDocumentElement(element);
|
|
@@ -6,21 +6,15 @@ import isNode from './isNode';
|
|
|
6
6
|
* Utility to determine if an `HTMLElement`
|
|
7
7
|
* is fully visible in the viewport.
|
|
8
8
|
*
|
|
9
|
-
* @param
|
|
10
|
-
* @return
|
|
9
|
+
* @param element target
|
|
10
|
+
* @return the query result
|
|
11
11
|
*/
|
|
12
|
-
const isElementInViewport = (element) => {
|
|
13
|
-
if (!
|
|
12
|
+
const isElementInViewport = (element?: HTMLElement): boolean => {
|
|
13
|
+
if (!isNode(element)) return false;
|
|
14
14
|
|
|
15
15
|
const { clientWidth, clientHeight } = getDocumentElement(element);
|
|
16
|
-
const {
|
|
17
|
-
top, left, bottom, right,
|
|
18
|
-
} = getBoundingClientRect(element, true);
|
|
16
|
+
const { top, left, bottom, right } = getBoundingClientRect(element, true);
|
|
19
17
|
|
|
20
|
-
return
|
|
21
|
-
top >= 0 && left >= 0
|
|
22
|
-
&& bottom <= clientHeight
|
|
23
|
-
&& right <= clientWidth
|
|
24
|
-
);
|
|
18
|
+
return top >= 0 && left >= 0 && bottom <= clientHeight && right <= clientWidth;
|
|
25
19
|
};
|
|
26
20
|
export default isElementInViewport;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import isHTMLElement from './isHTMLElement';
|
|
2
|
+
import isArray from './isArray';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Checks if an object is an `Array` in which all items are `Element`.
|
|
6
|
+
*
|
|
7
|
+
* @param obj the target object
|
|
8
|
+
* @returns the query result
|
|
9
|
+
*/
|
|
10
|
+
const isElementsArray = (obj?: unknown): obj is HTMLElement[] =>
|
|
11
|
+
(isArray(obj) && obj.every(isHTMLElement)) || false;
|
|
12
|
+
|
|
13
|
+
export default isElementsArray;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import isObject from './isObject';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Checks if an object is an `HTMLCollection`.
|
|
5
|
+
*
|
|
6
|
+
* @param obj the target object
|
|
7
|
+
* @returns the query result
|
|
8
|
+
*/
|
|
9
|
+
const isHTMLCollection = (obj?: unknown): obj is HTMLCollection =>
|
|
10
|
+
(isObject(obj) && obj.constructor.name === 'HTMLCollection') || false;
|
|
11
|
+
|
|
12
|
+
export default isHTMLCollection;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import isNode from './isNode';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Checks if an element is an `HTMLElement`.
|
|
5
|
+
*
|
|
6
|
+
* @see https://dom.spec.whatwg.org/#node
|
|
7
|
+
*
|
|
8
|
+
* @param element the target object
|
|
9
|
+
* @returns the query result
|
|
10
|
+
*/
|
|
11
|
+
const isHTMLElement = (element?: unknown): element is HTMLElement =>
|
|
12
|
+
(isNode(element) && element.nodeType === 1) || false;
|
|
13
|
+
export default isHTMLElement;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import isHTMLElement from './isHTMLElement';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Check if a target element is an `<img>`.
|
|
5
|
+
*
|
|
6
|
+
* @param element the target element
|
|
7
|
+
* @returns the query result
|
|
8
|
+
*/
|
|
9
|
+
const isHTMLImageElement = (element?: unknown): element is HTMLImageElement =>
|
|
10
|
+
(isHTMLElement(element) && element.tagName === 'IMG') || false;
|
|
11
|
+
|
|
12
|
+
export default isHTMLImageElement;
|
package/src/is/isJSON.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import isString from './isString';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Checks if a string is a `JSON` string.
|
|
5
|
+
*
|
|
6
|
+
* @param str the target string
|
|
7
|
+
* @returns the query result
|
|
8
|
+
*/
|
|
9
|
+
const isJSON = (str?: string): boolean => {
|
|
10
|
+
if (!isString(str)) return false;
|
|
11
|
+
|
|
12
|
+
try {
|
|
13
|
+
JSON.parse(str);
|
|
14
|
+
} catch (e) {
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
return true;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export default isJSON;
|
package/src/is/isMap.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import isObject from './isObject';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Checks if an element is a `Map`.
|
|
5
|
+
*
|
|
6
|
+
* @param obj the target object
|
|
7
|
+
* @returns the query result
|
|
8
|
+
*/
|
|
9
|
+
const isMap = (obj?: unknown): obj is Map<any, any> =>
|
|
10
|
+
(isObject(obj) && obj.constructor.name === 'Map') || false;
|
|
11
|
+
export default isMap;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import isNode from './isNode';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Checks if an element is an `<svg>` (or any type of SVG element),
|
|
5
|
+
* `<img>`, `<video>` or `<canvas>`.
|
|
6
|
+
*
|
|
7
|
+
* *Tooltip* / *Popover* works different with media elements.
|
|
8
|
+
*
|
|
9
|
+
* @param element the target element
|
|
10
|
+
* @returns the query result
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
const isMedia = (
|
|
14
|
+
element?: unknown,
|
|
15
|
+
): element is SVGElement | HTMLImageElement | HTMLVideoElement | HTMLCanvasElement =>
|
|
16
|
+
(isNode(element) &&
|
|
17
|
+
['SVG', 'Image', 'Video', 'Canvas'].some(s => element.constructor.name.includes(s))) ||
|
|
18
|
+
false;
|
|
19
|
+
|
|
20
|
+
export default isMedia;
|
package/src/is/isNode.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import isObject from './isObject';
|
|
2
|
+
|
|
3
|
+
type NodeObject = object & { nodeType: number };
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Checks if an object is a `Node`.
|
|
7
|
+
*
|
|
8
|
+
* @param node the target object
|
|
9
|
+
* @returns the query result
|
|
10
|
+
*/
|
|
11
|
+
const isNode = (node?: unknown): node is Node =>
|
|
12
|
+
(isObject(node) &&
|
|
13
|
+
typeof (node as NodeObject).nodeType === 'number' &&
|
|
14
|
+
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11].some(x => (node as NodeObject).nodeType === x)) ||
|
|
15
|
+
false;
|
|
16
|
+
|
|
17
|
+
export default isNode;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import isObject from './isObject';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Checks if an object is a `NodeList`.
|
|
5
|
+
* => equivalent to `object instanceof NodeList`
|
|
6
|
+
*
|
|
7
|
+
* @param obj the target object
|
|
8
|
+
* @returns the query result
|
|
9
|
+
*/
|
|
10
|
+
const isNodeList = (obj?: unknown): obj is NodeList =>
|
|
11
|
+
(isObject(obj) && obj.constructor.name === 'NodeList') || false;
|
|
12
|
+
|
|
13
|
+
export default isNodeList;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checks if a value is an `Object`.
|
|
3
|
+
*
|
|
4
|
+
* @param obj the target object
|
|
5
|
+
* @returns the query result
|
|
6
|
+
*/
|
|
7
|
+
const isObject = (obj?: unknown): obj is object =>
|
|
8
|
+
(obj !== null && obj !== undefined && typeof obj === 'object') || false;
|
|
9
|
+
|
|
10
|
+
export default isObject;
|
package/src/is/isRTL.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import getDocumentElement from '../get/getDocumentElement';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Checks if a page is Right To Left.
|
|
5
|
+
*
|
|
6
|
+
* @param node the target
|
|
7
|
+
* @returns the query result
|
|
8
|
+
*/
|
|
9
|
+
const isRTL = (node?: Node): boolean => getDocumentElement(node).dir === 'rtl';
|
|
10
|
+
|
|
11
|
+
export default isRTL;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import isNode from './isNode';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Check if an element is an `<svg>` or any other SVG element,
|
|
5
|
+
* an equivalent to `SOMETHING instanceof SVGElement`.
|
|
6
|
+
*
|
|
7
|
+
* @param element the target element
|
|
8
|
+
* @returns the query result
|
|
9
|
+
*/
|
|
10
|
+
const isSVGElement = (element?: unknown): element is SVGElement =>
|
|
11
|
+
(isNode(element) && element.constructor.name.includes('SVG')) || false;
|
|
12
|
+
|
|
13
|
+
export default isSVGElement;
|
|
@@ -3,15 +3,17 @@ import getBoundingClientRect from '../get/getBoundingClientRect';
|
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Checks if a target `HTMLElement` is affected by scale.
|
|
6
|
+
*
|
|
6
7
|
* @see https://github.com/floating-ui/floating-ui
|
|
7
8
|
*
|
|
8
|
-
* @param
|
|
9
|
-
* @returns
|
|
9
|
+
* @param element target
|
|
10
|
+
* @returns the query result
|
|
10
11
|
*/
|
|
11
|
-
|
|
12
|
-
if (!
|
|
12
|
+
const isScaledElement = (element?: HTMLElement): boolean => {
|
|
13
|
+
if (!isHTMLElement(element)) return false;
|
|
13
14
|
const { width, height } = getBoundingClientRect(element);
|
|
14
15
|
const { offsetWidth, offsetHeight } = element;
|
|
15
|
-
return Math.round(width) !== offsetWidth
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
return Math.round(width) !== offsetWidth || Math.round(height) !== offsetHeight;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export default isScaledElement;
|