@thednp/shorty 1.0.1 → 1.0.2

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.
Files changed (113) hide show
  1. package/README.md +12 -7
  2. package/dist/shorty.esm.js +379 -312
  3. package/dist/shorty.esm.min.js +2 -2
  4. package/dist/shorty.js +392 -319
  5. package/dist/shorty.min.js +2 -2
  6. package/package.json +11 -2
  7. package/src/attr/getAttribute.js +1 -1
  8. package/src/attr/getAttributeNS.js +1 -1
  9. package/src/attr/hasAttribute.js +1 -1
  10. package/src/attr/hasAttributeNS.js +1 -1
  11. package/src/attr/removeAttribute.js +1 -1
  12. package/src/attr/removeAttributeNS.js +1 -1
  13. package/src/attr/setAttribute.js +1 -1
  14. package/src/attr/setAttributeNS.js +1 -1
  15. package/src/boolean/isApple.js +2 -2
  16. package/src/boolean/isFirefox.js +2 -1
  17. package/src/boolean/isMobile.js +2 -2
  18. package/src/boolean/support3DTransform.js +2 -1
  19. package/src/boolean/supportAnimation.js +2 -1
  20. package/src/boolean/supportPassive.js +1 -1
  21. package/src/boolean/supportTouch.js +2 -1
  22. package/src/boolean/supportTransform.js +2 -1
  23. package/src/boolean/supportTransition.js +2 -1
  24. package/src/class/addClass.js +1 -1
  25. package/src/class/hasClass.js +1 -1
  26. package/src/class/removeClass.js +1 -1
  27. package/src/event/off.js +2 -6
  28. package/src/event/on.js +2 -6
  29. package/src/event/one.js +3 -6
  30. package/src/get/getBoundingClientRect.js +9 -5
  31. package/src/get/getDocument.js +8 -3
  32. package/src/get/getDocumentBody.js +2 -2
  33. package/src/get/getDocumentElement.js +2 -2
  34. package/src/get/getDocumentHead.js +2 -2
  35. package/src/get/getElementAnimationDelay.js +3 -3
  36. package/src/get/getElementAnimationDelayLegacy.js +3 -3
  37. package/src/get/getElementAnimationDuration.js +3 -3
  38. package/src/get/getElementAnimationDurationLegacy.js +3 -3
  39. package/src/get/getElementStyle.js +5 -3
  40. package/src/get/getElementTransitionDelay.js +3 -4
  41. package/src/get/getElementTransitionDelayLegacy.js +3 -3
  42. package/src/get/getElementTransitionDuration.js +3 -3
  43. package/src/get/getElementTransitionDurationLegacy.js +3 -3
  44. package/src/get/getNodeScroll.js +1 -1
  45. package/src/get/getParentNode.js +4 -5
  46. package/src/get/getRectRelativeToOffsetParent.js +7 -5
  47. package/src/get/getUID.js +1 -1
  48. package/src/get/getWindow.js +16 -7
  49. package/src/index.js +10 -6
  50. package/src/is/isArray.js +0 -1
  51. package/src/is/isCustomElement.js +1 -1
  52. package/src/is/isDocument.js +3 -2
  53. package/src/is/isElement.js +14 -1
  54. package/src/is/isElementInScrollRange.js +4 -2
  55. package/src/is/isElementInViewport.js +6 -2
  56. package/src/is/isElementsArray.js +3 -1
  57. package/src/is/isFunction.js +2 -3
  58. package/src/is/isHTMLCollection.js +1 -1
  59. package/src/is/isHTMLElement.js +2 -1
  60. package/src/is/isHTMLImageElement.js +1 -1
  61. package/src/is/isMedia.js +5 -3
  62. package/src/is/isNode.js +2 -1
  63. package/src/is/isNodeList.js +2 -1
  64. package/src/is/isNumber.js +8 -0
  65. package/src/is/isRTL.js +1 -1
  66. package/src/is/isSVGElement.js +4 -1
  67. package/src/is/isScaledElement.js +2 -0
  68. package/src/is/isShadowRoot.js +2 -5
  69. package/src/is/isString.js +2 -2
  70. package/src/is/isTableElement.js +5 -1
  71. package/src/is/isWindow.js +5 -5
  72. package/src/misc/ObjectEntries.js +7 -0
  73. package/src/misc/OriginalEvent.js +2 -1
  74. package/src/misc/createElement.js +3 -1
  75. package/src/misc/createElementNS.js +7 -3
  76. package/src/misc/data.js +16 -16
  77. package/src/misc/dispatchEvent.js +1 -1
  78. package/src/misc/emulateAnimationEnd.js +5 -2
  79. package/src/misc/emulateAnimationEndLegacy.js +9 -6
  80. package/src/misc/emulateTransitionEnd.js +5 -2
  81. package/src/misc/emulateTransitionEndLegacy.js +9 -6
  82. package/src/misc/focus.js +1 -2
  83. package/src/misc/normalizeOptions.js +2 -2
  84. package/src/misc/normalizeValue.js +8 -6
  85. package/src/misc/passiveHandlerLegacy.js +2 -1
  86. package/src/misc/reflow.js +1 -2
  87. package/src/misc/setElementStyle.js +12 -3
  88. package/src/misc/timer.js +16 -19
  89. package/src/misc/version.js +0 -1
  90. package/src/selectors/closest.js +3 -3
  91. package/src/selectors/getCustomElements.js +4 -5
  92. package/src/selectors/getElementById.js +6 -3
  93. package/src/selectors/getElementsByClassName.js +4 -3
  94. package/src/selectors/getElementsByTagName.js +4 -3
  95. package/src/selectors/matches.js +1 -1
  96. package/src/selectors/matchesLegacy.js +8 -8
  97. package/src/selectors/querySelector.js +9 -7
  98. package/src/selectors/querySelectorAll.js +4 -3
  99. package/src/strings/animationDelayLegacy.js +2 -1
  100. package/src/strings/animationDurationLegacy.js +2 -1
  101. package/src/strings/animationEndEventLegacy.js +2 -1
  102. package/src/strings/animationNameLegacy.js +2 -1
  103. package/src/strings/mouseHoverEvents.js +2 -1
  104. package/src/strings/transitionDelayLegacy.js +2 -1
  105. package/src/strings/transitionDurationLegacy.js +2 -1
  106. package/src/strings/transitionEndEventLegacy.js +2 -1
  107. package/src/strings/transitionPropertyLegacy.js +2 -2
  108. package/src/strings/userAgentData.js +0 -1
  109. package/types/index.d.ts +9 -3
  110. package/types/module/shorty.ts +2 -2
  111. package/types/shorty.d.ts +237 -224
  112. package/src/misc/tryWrapper.js +0 -11
  113. package/src/selectors/documentAll.js +0 -8
package/dist/shorty.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * Shorty v1.0.1 (https://github.com/thednp/shorty)
2
+ * Shorty v1.0.2 (https://github.com/thednp/shorty)
3
3
  * Copyright 2019-2022 © dnp_theme
4
4
  * Licensed under MIT (https://github.com/thednp/shorty/blob/master/LICENSE)
5
5
  */
@@ -479,7 +479,8 @@
479
479
  * A global namespace for mouse hover events.
480
480
  * @type {[string, string]}
481
481
  */
482
- var mouseHoverEvents = ('onmouseleave' in document) ? ['mouseenter', 'mouseleave'] : ['mouseover', 'mouseout'];
482
+ var mouseHoverEvents = ('onmouseleave' in document) ? ['mouseenter', 'mouseleave']
483
+ : /* istanbul ignore next */['mouseover', 'mouseout'];
483
484
 
484
485
  /**
485
486
  * A global namespace for touch events.
@@ -644,7 +645,8 @@
644
645
  * A global namespace for 'animationDuration' string.
645
646
  * @type {string}
646
647
  */
647
- var animationDuration = 'webkitAnimation' in documentHead.style ? 'webkitAnimationDuration' : 'animationDuration';
648
+ var animationDuration = 'webkitAnimation' in documentHead.style ? 'webkitAnimationDuration'
649
+ : /* istanbul ignore next */'animationDuration';
648
650
 
649
651
  /**
650
652
  * A global namespace for 'animationDelay' string.
@@ -656,7 +658,8 @@
656
658
  * A global namespace for 'animationDelay' string.
657
659
  * @type {string}
658
660
  */
659
- var animationDelay = 'webkitAnimation' in documentHead.style ? 'webkitAnimationDelay' : 'animationDelay';
661
+ var animationDelay = 'webkitAnimation' in documentHead.style ? 'webkitAnimationDelay'
662
+ : /* istanbul ignore next */'animationDelay';
660
663
 
661
664
  /**
662
665
  * A global namespace for 'animationName' string.
@@ -668,7 +671,8 @@
668
671
  * A global namespace for 'animationName' string.
669
672
  * @type {string}
670
673
  */
671
- var animationName = 'webkitAnimation' in documentHead.style ? 'webkitAnimationName' : 'animationName';
674
+ var animationName = 'webkitAnimation' in documentHead.style ? 'webkitAnimationName'
675
+ : /* istanbul ignore next */'animationName';
672
676
 
673
677
  /**
674
678
  * A global namespace for 'animationend' string.
@@ -680,7 +684,8 @@
680
684
  * A global namespace for 'animationend' string.
681
685
  * @type {string}
682
686
  */
683
- var animationEndEvent = 'webkitAnimation' in documentHead.style ? 'webkitAnimationEnd' : 'animationend';
687
+ var animationEndEvent = 'webkitAnimation' in documentHead.style ? 'webkitAnimationEnd'
688
+ : /* istanbul ignore next */'animationend';
684
689
 
685
690
  /**
686
691
  * A global namespace for 'transitionDuration' string.
@@ -692,7 +697,8 @@
692
697
  * A global namespace for 'transitionDuration' string.
693
698
  * @type {string}
694
699
  */
695
- var transitionDuration = 'webkitTransition' in documentHead.style ? 'webkitTransitionDuration' : 'transitionDuration';
700
+ var transitionDuration = 'webkitTransition' in documentHead.style ? 'webkitTransitionDuration'
701
+ : /* istanbul ignore next */'transitionDuration';
696
702
 
697
703
  /**
698
704
  * A global namespace for 'transitionDelay' string.
@@ -704,7 +710,8 @@
704
710
  * A global namespace for 'transitionDelay' string.
705
711
  * @type {string}
706
712
  */
707
- var transitionDelay = 'webkitTransition' in documentHead.style ? 'webkitTransitionDelay' : 'transitionDelay';
713
+ var transitionDelay = 'webkitTransition' in documentHead.style ? 'webkitTransitionDelay'
714
+ : /* istanbul ignore next */'transitionDelay';
708
715
 
709
716
  /**
710
717
  * A global namespace for 'transitionend' string.
@@ -716,7 +723,8 @@
716
723
  * A global namespace for 'transitionend' string.
717
724
  * @type {string}
718
725
  */
719
- var transitionEndEvent = 'webkitTransition' in documentHead.style ? 'webkitTransitionEnd' : 'transitionend';
726
+ var transitionEndEvent = 'webkitTransition' in documentHead.style ? 'webkitTransitionEnd'
727
+ : /* istanbul ignore next */'transitionend';
720
728
 
721
729
  /**
722
730
  * A global namespace for `transitionProperty` string for modern browsers.
@@ -732,7 +740,8 @@
732
740
  *
733
741
  * @type {string}
734
742
  */
735
- var transitionProperty = 'webkitTransition' in documentHead.style ? 'webkitTransitionProperty' : 'transitionProperty';
743
+ var transitionProperty = 'webkitTransition' in documentHead.style ? 'webkitTransitionProperty'
744
+ : /* istanbul ignore next */'transitionProperty';
736
745
 
737
746
  /**
738
747
  * A global namespace for 'addEventListener' string.
@@ -803,7 +812,6 @@
803
812
  */
804
813
  var scrollWidth = 'scrollWidth';
805
814
 
806
- // @ts-ignore
807
815
  var uaDATA = navigator.userAgentData;
808
816
 
809
817
  /**
@@ -821,9 +829,9 @@
821
829
  var mobileBrands = /iPhone|iPad|iPod|Android/i;
822
830
  var isMobileCheck = false;
823
831
 
832
+ /* istanbul ignore else */
824
833
  if (userAgentData) {
825
- isMobileCheck = userAgentData.brands
826
- .some(function (/** @type {Record<String, any>} */x) { return mobileBrands.test(x.brand); });
834
+ isMobileCheck = userAgentData.brands.some(function (x) { return mobileBrands.test(x.brand); });
827
835
  } else {
828
836
  isMobileCheck = mobileBrands.test(userAgent);
829
837
  }
@@ -840,30 +848,28 @@
840
848
  * A global `boolean` for Apple browsers.
841
849
  * @type {boolean}
842
850
  */
843
- var isApple = !userAgentData ? appleBrands.test(userAgent)
844
- : userAgentData.brands.some(function (/** @type {Record<string, any>} */x) { return appleBrands.test(x.brand); });
851
+ var isApple = userAgentData ? userAgentData.brands.some(function (x) { return appleBrands.test(x.brand); })
852
+ : /* istanbul ignore next */appleBrands.test(userAgent);
845
853
 
846
854
  /**
847
855
  * A global boolean for Gecko browsers. When writing this file,
848
856
  * Gecko was not supporting `userAgentData`.
849
857
  * @type {boolean}
850
858
  */
851
- var isFirefox = userAgent ? userAgent.includes('Firefox') : false;
859
+ var isFirefox = userAgent ? userAgent.includes('Firefox')
860
+ : /* istanbul ignore next */false;
852
861
 
853
862
  /**
854
863
  * A global `boolean` for CSS3 3D transform support.
855
864
  * @type {boolean}
856
865
  */
857
- var support3DTransform = 'webkitPerspective' in documentHead.style || 'perspective' in documentHead.style;
866
+ var support3DTransform = 'webkitPerspective' in documentHead.style
867
+ || /* istanbul ignore next */'perspective' in documentHead.style;
858
868
 
859
869
  /**
860
- * Add eventListener to an `Element` | `HTMLElement` | `Document` target.
870
+ * Add eventListener to an `HTMLElement` | `Document` target.
861
871
  *
862
- * @param {HTMLElement | Element | Document | Window} element event.target
863
- * @param {string} eventName event.type
864
- * @param {EventListener} listener callback
865
- * @param {(EventListenerOptions | boolean)=} options other event options
866
- * @returns {void}
872
+ * @type {SHORTY.OnOff<EventTarget>}
867
873
  */
868
874
  function on(element, eventName, listener, options) {
869
875
  var ops = options || false;
@@ -871,13 +877,9 @@
871
877
  }
872
878
 
873
879
  /**
874
- * Remove eventListener from an `Element` | `HTMLElement` | `Document` | `Window` target.
880
+ * Remove eventListener from an `HTMLElement` | `Document` | `Window` target.
875
881
  *
876
- * @param {HTMLElement | Element | Document | Window} element event.target
877
- * @param {string} eventName event.type
878
- * @param {EventListener} listener callback
879
- * @param {(EventListenerOptions | boolean)=} options other event options
880
- * @returns {void}
882
+ * @type {SHORTY.OnOff<EventTarget>}
881
883
  */
882
884
  function off(element, eventName, listener, options) {
883
885
  var ops = options || false;
@@ -885,14 +887,10 @@
885
887
  }
886
888
 
887
889
  /**
888
- * Add an `eventListener` to an `Element` | `HTMLElement` | `Document` | `Window`
890
+ * Add an `eventListener` to an `HTMLElement` | `Document` | `Window`
889
891
  * target and remove it once callback is called.
890
892
  *
891
- * @param {HTMLElement | Element | Document | Window} element event.target
892
- * @param {string} eventName event.type
893
- * @param {EventListener} listener callback
894
- * @param {(EventListenerOptions | boolean)=} options other event options
895
- * @returns {void}
893
+ * @type {SHORTY.OnOff<EventTarget>}
896
894
  */
897
895
  function one(element, eventName, listener, options) {
898
896
  /**
@@ -900,6 +898,7 @@
900
898
  * @type {EventListener}
901
899
  */
902
900
  var handlerWrapper = function (e) {
901
+ /* istanbul ignore else */
903
902
  if (e.target === element) {
904
903
  listener.apply(element, [e]);
905
904
  off(element, eventName, handlerWrapper, options);
@@ -926,7 +925,7 @@
926
925
  });
927
926
  one(document, DOMContentLoadedEvent, function () {}, opts);
928
927
  } catch (e) {
929
- throw Error('Passive events are not supported');
928
+ // throw Error('Passive events are not supported');
930
929
  }
931
930
 
932
931
  return result;
@@ -936,29 +935,33 @@
936
935
  * A global `boolean` for CSS3 transform support.
937
936
  * @type {boolean}
938
937
  */
939
- var supportTransform = 'webkitTransform' in documentHead.style || 'transform' in documentHead.style;
938
+ var supportTransform = 'webkitTransform' in documentHead.style
939
+ || /* istanbul ignore next */'transform' in documentHead.style;
940
940
 
941
941
  /**
942
942
  * A global `boolean` for touch events support.
943
943
  * @type {boolean}
944
944
  */
945
- var supportTouch = 'ontouchstart' in window || 'msMaxTouchPoints' in navigator;
945
+ var supportTouch = 'ontouchstart' in window
946
+ || /* istanbul ignore next */'msMaxTouchPoints' in navigator;
946
947
 
947
948
  /**
948
949
  * A global `boolean` for CSS3 animation support.
949
950
  * @type {boolean}
950
951
  */
951
- var supportAnimation = 'webkitAnimation' in documentHead.style || 'animation' in documentHead.style;
952
+ var supportAnimation = 'webkitAnimation' in documentHead.style
953
+ || /* istanbul ignore next */'animation' in documentHead.style;
952
954
 
953
955
  /**
954
956
  * A global `boolean` for CSS3 transition support.
955
957
  * @type {boolean}
956
958
  */
957
- var supportTransition = 'webkitTransition' in documentHead.style || 'transition' in documentHead.style;
959
+ var supportTransition = 'webkitTransition' in documentHead.style
960
+ || /* istanbul ignore next */'transition' in documentHead.style;
958
961
 
959
962
  /**
960
963
  * Shortcut for `HTMLElement.getAttribute()` method.
961
- * @param {HTMLElement | Element} element target element
964
+ * @param {HTMLElement} element target element
962
965
  * @param {string} attribute attribute name
963
966
  * @returns {string?} attribute value
964
967
  */
@@ -967,7 +970,7 @@
967
970
  /**
968
971
  * Shortcut for `HTMLElement.getAttributeNS()` method.
969
972
  * @param {string} ns attribute namespace
970
- * @param {HTMLElement | Element} element target element
973
+ * @param {HTMLElement} element target element
971
974
  * @param {string} attribute attribute name
972
975
  * @returns {string?} attribute value
973
976
  */
@@ -975,7 +978,7 @@
975
978
 
976
979
  /**
977
980
  * Shortcut for `HTMLElement.hasAttribute()` method.
978
- * @param {HTMLElement | Element} element target element
981
+ * @param {HTMLElement} element target element
979
982
  * @param {string} attribute attribute name
980
983
  * @returns {boolean} the query result
981
984
  */
@@ -984,7 +987,7 @@
984
987
  /**
985
988
  * Shortcut for `HTMLElement.hasAttributeNS()` method.
986
989
  * @param {string} ns attribute namespace
987
- * @param {HTMLElement | Element} element target element
990
+ * @param {HTMLElement} element target element
988
991
  * @param {string} att attribute name
989
992
  * @returns {boolean} the query result
990
993
  */
@@ -992,7 +995,7 @@
992
995
 
993
996
  /**
994
997
  * Shortcut for `HTMLElement.setAttribute()` method.
995
- * @param {HTMLElement | Element} element target element
998
+ * @param {HTMLElement} element target element
996
999
  * @param {string} attribute attribute name
997
1000
  * @param {string} value attribute value
998
1001
  * @returns {void}
@@ -1002,7 +1005,7 @@
1002
1005
  /**
1003
1006
  * Shortcut for `SVGElement.setAttributeNS()` method.
1004
1007
  * @param {string} ns attribute namespace
1005
- * @param {HTMLElement | Element} element target element
1008
+ * @param {HTMLElement} element target element
1006
1009
  * @param {string} att attribute name
1007
1010
  * @param {string} value attribute value
1008
1011
  * @returns {void}
@@ -1011,7 +1014,7 @@
1011
1014
 
1012
1015
  /**
1013
1016
  * Shortcut for `HTMLElement.removeAttribute()` method.
1014
- * @param {HTMLElement | Element} element target element
1017
+ * @param {HTMLElement} element target element
1015
1018
  * @param {string} attribute attribute name
1016
1019
  * @returns {void}
1017
1020
  */
@@ -1020,7 +1023,7 @@
1020
1023
  /**
1021
1024
  * Shortcut for `HTMLElement.removeAttributeNS()` method.
1022
1025
  * @param {string} ns attribute namespace
1023
- * @param {HTMLElement | Element} element target element
1026
+ * @param {HTMLElement} element target element
1024
1027
  * @param {string} att attribute name
1025
1028
  * @returns {void}
1026
1029
  */
@@ -1029,7 +1032,7 @@
1029
1032
  /**
1030
1033
  * Add class to `HTMLElement.classList`.
1031
1034
  *
1032
- * @param {HTMLElement | Element} element target
1035
+ * @param {HTMLElement} element target
1033
1036
  * @param {string} classNAME to add
1034
1037
  * @returns {void}
1035
1038
  */
@@ -1040,7 +1043,7 @@
1040
1043
  /**
1041
1044
  * Remove class from `HTMLElement.classList`.
1042
1045
  *
1043
- * @param {HTMLElement | Element} element target
1046
+ * @param {HTMLElement} element target
1044
1047
  * @param {string} classNAME to remove
1045
1048
  * @returns {void}
1046
1049
  */
@@ -1051,7 +1054,7 @@
1051
1054
  /**
1052
1055
  * Check class in `HTMLElement.classList`.
1053
1056
  *
1054
- * @param {HTMLElement | Element} element target
1057
+ * @param {HTMLElement} element target
1055
1058
  * @param {string} classNAME to check
1056
1059
  * @returns {boolean}
1057
1060
  */
@@ -1068,34 +1071,15 @@
1068
1071
  var ArrayFrom = function (arr) { return Array.from(arr); };
1069
1072
 
1070
1073
  /**
1071
- * Returns the `document` or the `#document` element.
1072
- * @see https://github.com/floating-ui/floating-ui
1073
- * @param {(Node | HTMLElement | Element | globalThis)=} node
1074
- * @returns {Document}
1075
- */
1076
- function getDocument(node) {
1077
- if (node instanceof HTMLElement) { return node.ownerDocument; }
1078
- if (node instanceof Window) { return node.document; }
1079
- return window.document;
1080
- }
1081
-
1082
- /**
1083
- * Utility to check if target is typeof `HTMLElement`, `Element`, `Node`
1084
- * or find one that matches a selector.
1074
+ * Checks if an element is an `HTMLElement`.
1075
+ * @see https://dom.spec.whatwg.org/#node
1085
1076
  *
1086
- * @param {Node | HTMLElement | Element | string} selector the input selector or target element
1087
- * @param {(Node | HTMLElement | Element | Document)=} parent optional node to look into
1088
- * @return {(HTMLElement | Element)?} the `HTMLElement` or `querySelector` result
1077
+ * @param {any} element the target object
1078
+ * @returns {boolean} the query result
1089
1079
  */
1090
- function querySelector(selector, parent) {
1091
- if (typeof selector === 'string') {
1092
- var lookUp = typeof parent !== 'object' ? getDocument() : parent;
1093
- return lookUp.querySelector(selector);
1094
- }
1095
- return selector;
1096
- }
1080
+ var isHTMLElement = function (element) { return (element && element.nodeType === 1) || false; };
1097
1081
 
1098
- /** @type {Map<string, Map<HTMLElement | Element, Record<string, any>>>} */
1082
+ /** @type {Map<string, Map<HTMLElement, Record<string, any>>>} */
1099
1083
  var componentData = new Map();
1100
1084
  /**
1101
1085
  * An interface for web components background data.
@@ -1104,27 +1088,27 @@
1104
1088
  var Data = {
1105
1089
  /**
1106
1090
  * Sets web components data.
1107
- * @param {HTMLElement | Element | string} target target element
1091
+ * @param {HTMLElement} element target element
1108
1092
  * @param {string} component the component's name or a unique key
1109
1093
  * @param {Record<string, any>} instance the component instance
1110
1094
  */
1111
- set: function (target, component, instance) {
1112
- var element = querySelector(target);
1113
- if (!element) { return; }
1095
+ set: function (element, component, instance) {
1096
+ if (!isHTMLElement(element)) { return; }
1114
1097
 
1098
+ /* istanbul ignore else */
1115
1099
  if (!componentData.has(component)) {
1116
1100
  componentData.set(component, new Map());
1117
1101
  }
1118
1102
 
1119
1103
  var instanceMap = componentData.get(component);
1120
- // @ts-ignore - not undefined, but defined right above
1104
+ // not undefined, but defined right above
1121
1105
  instanceMap.set(element, instance);
1122
1106
  },
1123
1107
 
1124
1108
  /**
1125
1109
  * Returns all instances for specified component.
1126
1110
  * @param {string} component the component's name or a unique key
1127
- * @returns {Map<HTMLElement | Element, Record<string, any>>?} all the component instances
1111
+ * @returns {Map<HTMLElement, Record<string, any>>?} all the component instances
1128
1112
  */
1129
1113
  getAllFor: function (component) {
1130
1114
  var instanceMap = componentData.get(component);
@@ -1134,12 +1118,12 @@
1134
1118
 
1135
1119
  /**
1136
1120
  * Returns the instance associated with the target.
1137
- * @param {HTMLElement | Element | string} target target element
1121
+ * @param {HTMLElement} element target element
1138
1122
  * @param {string} component the component's name or a unique key
1139
1123
  * @returns {Record<string, any>?} the instance
1140
1124
  */
1141
- get: function (target, component) {
1142
- var element = querySelector(target);
1125
+ get: function (element, component) {
1126
+ if (!isHTMLElement(element) || !component) { return null; }
1143
1127
  var allForC = Data.getAllFor(component);
1144
1128
  var instance = element && allForC && allForC.get(element);
1145
1129
 
@@ -1148,16 +1132,16 @@
1148
1132
 
1149
1133
  /**
1150
1134
  * Removes web components data.
1151
- * @param {HTMLElement | Element | string} target target element
1135
+ * @param {HTMLElement} element target element
1152
1136
  * @param {string} component the component's name or a unique key
1153
1137
  */
1154
- remove: function (target, component) {
1155
- var element = querySelector(target);
1138
+ remove: function (element, component) {
1156
1139
  var instanceMap = componentData.get(component);
1157
- if (!instanceMap || !element) { return; }
1140
+ if (!instanceMap || !isHTMLElement(element)) { return; }
1158
1141
 
1159
1142
  instanceMap.delete(element);
1160
1143
 
1144
+ /* istanbul ignore else */
1161
1145
  if (instanceMap.size === 0) {
1162
1146
  componentData.delete(component);
1163
1147
  }
@@ -1166,10 +1150,50 @@
1166
1150
 
1167
1151
  /**
1168
1152
  * An alias for `Data.get()`.
1169
- * @type {SHORTER.getInstance<any>}
1153
+ * @type {SHORTY.getInstance<any>}
1170
1154
  */
1171
1155
  var getInstance = function (target, component) { return Data.get(target, component); };
1172
1156
 
1157
+ /**
1158
+ * Checks if an object is a `Document`.
1159
+ * @see https://dom.spec.whatwg.org/#node
1160
+ *
1161
+ * @param {any} object the target object
1162
+ * @returns {boolean} the query result
1163
+ */
1164
+ var isDocument = function (object) { return (object && object.nodeType === 9) || false; };
1165
+
1166
+ /**
1167
+ * Checks if an object is a `Node`.
1168
+ *
1169
+ * @param {any} node the target object
1170
+ * @returns {boolean} the query result
1171
+ */
1172
+ var isNode = function (element) { return (element && [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]
1173
+ .some(function (x) { return +element.nodeType === x; })) || false; };
1174
+
1175
+ /**
1176
+ * Check if a target object is `Window`.
1177
+ * => equivalent to `object instanceof Window`
1178
+ *
1179
+ * @param {any} object the target object
1180
+ * @returns {boolean} the query result
1181
+ */
1182
+ var isWindow = function (object) { return (object && object.constructor.name === 'Window') || false; };
1183
+
1184
+ /**
1185
+ * Returns the `document` or the `#document` element.
1186
+ * @see https://github.com/floating-ui/floating-ui
1187
+ * @param {(ParentNode | Window)=} node
1188
+ * @returns {Document}
1189
+ */
1190
+ function getDocument(node) {
1191
+ if (isDocument(node)) { return node; }
1192
+ if (isNode(node)) { return node.ownerDocument; }
1193
+ if (isWindow(node)) { return node.document; }
1194
+ return window.document;
1195
+ }
1196
+
1173
1197
  /**
1174
1198
  * Shortcut for `Object.assign()` static method.
1175
1199
  * @param {Record<string, any>} obj a target object
@@ -1185,9 +1209,11 @@
1185
1209
  * @see https://developer.mozilla.org/en-US/docs/Web/API/Document/createElement
1186
1210
  *
1187
1211
  * @param {Record<string, string> | string} param `tagName` or object
1188
- * @return {HTMLElement | Element} a new `HTMLElement` or `Element`
1212
+ * @return {HTMLElement} a new `HTMLElement` or `Element`
1189
1213
  */
1190
1214
  function createElement(param) {
1215
+ if (!param) { return null; }
1216
+
1191
1217
  if (typeof param === 'string') {
1192
1218
  return getDocument().createElement(param);
1193
1219
  }
@@ -1200,6 +1226,13 @@
1200
1226
  return newElement;
1201
1227
  }
1202
1228
 
1229
+ /**
1230
+ * Shortcut for `Object.entries()` static method.
1231
+ * @param {Record<string, any>} obj a target object
1232
+ * @returns {[string, any][]}
1233
+ */
1234
+ var ObjectEntries = function (obj) { return Object.entries(obj); };
1235
+
1203
1236
  /**
1204
1237
  * This is a shortie for `document.createElementNS` method
1205
1238
  * which allows you to create a new `HTMLElement` for a given `tagName`
@@ -1209,9 +1242,10 @@
1209
1242
  *
1210
1243
  * @param {string} namespace `namespaceURI` to associate with the new `HTMLElement`
1211
1244
  * @param {Record<string, string> | string} param `tagName` or object
1212
- * @return {HTMLElement | Element} a new `HTMLElement` or `Element`
1245
+ * @return {HTMLElement} a new `HTMLElement` or `Element`
1213
1246
  */
1214
1247
  function createElementNS(namespace, param) {
1248
+ if (!namespace && !param) { return null; }
1215
1249
  if (typeof param === 'string') {
1216
1250
  return getDocument().createElementNS(namespace, param);
1217
1251
  }
@@ -1220,14 +1254,19 @@
1220
1254
  var attr = Object.assign({}, param);
1221
1255
  var newElement = createElementNS(namespace, tagName);
1222
1256
  delete attr.tagName;
1223
- ObjectAssign(newElement, attr);
1257
+ ObjectEntries(attr).forEach(function (ref) {
1258
+ var key = ref[0];
1259
+ var value = ref[1];
1260
+
1261
+ setAttribute(newElement, key, value);
1262
+ });
1224
1263
  return newElement;
1225
1264
  }
1226
1265
 
1227
1266
  /**
1228
1267
  * Shortcut for the `Element.dispatchEvent(Event)` method.
1229
1268
  *
1230
- * @param {HTMLElement | Element} element is the target
1269
+ * @param {HTMLElement} element is the target
1231
1270
  * @param {Event} event is the `Event` object
1232
1271
  */
1233
1272
  var dispatchEvent = function (element, event) { return element.dispatchEvent(event); };
@@ -1249,33 +1288,35 @@
1249
1288
  * * If `element` parameter is not an `HTMLElement`, `getComputedStyle`
1250
1289
  * throws a `ReferenceError`.
1251
1290
  *
1252
- * @param {HTMLElement | Element} element target
1291
+ * @param {HTMLElement} element target
1253
1292
  * @param {string} property the css property
1254
1293
  * @return {string} the css property value
1255
1294
  */
1256
1295
  function getElementStyle(element, property) {
1257
1296
  var computedStyle = getComputedStyle(element);
1258
1297
 
1259
- // @ts-ignore -- must use camelcase strings,
1298
+ // must use camelcase strings,
1260
1299
  // or non-camelcase strings with `getPropertyValue`
1261
- return property in computedStyle ? computedStyle[property] : '';
1300
+ return property.includes('--')
1301
+ ? computedStyle.getPropertyValue(property)
1302
+ : computedStyle[property];
1262
1303
  }
1263
1304
 
1264
1305
  /**
1265
1306
  * Utility to get the computed `animationDelay`
1266
1307
  * from Element in miliseconds.
1267
1308
  *
1268
- * @param {HTMLElement | Element} element target
1309
+ * @param {HTMLElement} element target
1269
1310
  * @return {number} the value in miliseconds
1270
1311
  */
1271
1312
  function getElementAnimationDelay$1(element) {
1272
1313
  var propertyValue = getElementStyle(element, animationName$1);
1273
1314
  var durationValue = getElementStyle(element, animationDelay$1);
1274
-
1275
- var durationScale = durationValue.includes('ms') ? 1 : 1000;
1315
+ var durationScale = durationValue.includes('ms') ? /* istanbul ignore next */1 : 1000;
1276
1316
  var duration = propertyValue && propertyValue !== 'none'
1277
1317
  ? parseFloat(durationValue) * durationScale : 0;
1278
1318
 
1319
+ /* istanbul ignore next */
1279
1320
  return !Number.isNaN(duration) ? duration : 0;
1280
1321
  }
1281
1322
 
@@ -1283,24 +1324,24 @@
1283
1324
  * Utility to get the computed `animationDuration`
1284
1325
  * from `HTMLElement` in miliseconds.
1285
1326
  *
1286
- * @param {HTMLElement | Element} element target
1327
+ * @param {HTMLElement} element target
1287
1328
  * @return {number} the value in miliseconds
1288
1329
  */
1289
1330
  function getElementAnimationDuration$1(element) {
1290
1331
  var propertyValue = getElementStyle(element, animationName$1);
1291
1332
  var durationValue = getElementStyle(element, animationDuration$1);
1292
- var durationScale = durationValue.includes('ms') ? 1 : 1000;
1333
+ var durationScale = durationValue.includes('ms') ? /* istanbul ignore next */1 : 1000;
1293
1334
  var duration = propertyValue && propertyValue !== 'none'
1294
1335
  ? parseFloat(durationValue) * durationScale : 0;
1295
1336
 
1296
- return !Number.isNaN(duration) ? duration : 0;
1337
+ return !Number.isNaN(duration) ? duration : /* istanbul ignore next */0;
1297
1338
  }
1298
1339
 
1299
1340
  /**
1300
1341
  * Utility to make sure callbacks are consistently
1301
1342
  * called when animation ends.
1302
1343
  *
1303
- * @param {HTMLElement | Element} element target
1344
+ * @param {HTMLElement} element target
1304
1345
  * @param {EventListener} handler `animationend` callback
1305
1346
  */
1306
1347
  function emulateAnimationEnd$1(element, handler) {
@@ -1315,6 +1356,7 @@
1315
1356
  * @type {EventListener}
1316
1357
  */
1317
1358
  var animationEndWrapper = function (e) {
1359
+ /* istanbul ignore else */
1318
1360
  if (e.target === element) {
1319
1361
  handler.apply(element, [e]);
1320
1362
  element.removeEventListener(animationEndEvent$1, animationEndWrapper);
@@ -1323,7 +1365,8 @@
1323
1365
  };
1324
1366
  element.addEventListener(animationEndEvent$1, animationEndWrapper);
1325
1367
  setTimeout(function () {
1326
- if (!called) { element.dispatchEvent(endEvent); }
1368
+ /* istanbul ignore next */
1369
+ if (!called) { dispatchEvent(element, endEvent); }
1327
1370
  }, duration + delay + 17);
1328
1371
  } else {
1329
1372
  handler.apply(element, [endEvent]);
@@ -1334,41 +1377,41 @@
1334
1377
  * Utility to get the computed `animationDelay`
1335
1378
  * from Element in miliseconds.
1336
1379
  *
1337
- * @param {HTMLElement | Element} element target
1380
+ * @param {HTMLElement} element target
1338
1381
  * @return {number} the value in miliseconds
1339
1382
  */
1340
1383
  function getElementAnimationDelay(element) {
1341
1384
  var propertyValue = getElementStyle(element, animationName);
1342
1385
  var durationValue = getElementStyle(element, animationDelay);
1343
- var durationScale = durationValue.includes('ms') ? 1 : 1000;
1386
+ var durationScale = durationValue.includes('ms') ? /* istanbul ignore next */1 : 1000;
1344
1387
  var duration = supportAnimation && propertyValue && propertyValue !== 'none'
1345
1388
  ? parseFloat(durationValue) * durationScale : 0;
1346
1389
 
1347
- return !Number.isNaN(duration) ? duration : 0;
1390
+ return !Number.isNaN(duration) ? duration : /* istanbul ignore next */0;
1348
1391
  }
1349
1392
 
1350
1393
  /**
1351
1394
  * Utility to get the computed `animationDuration`
1352
1395
  * from `HTMLElement` in miliseconds.
1353
1396
  *
1354
- * @param {HTMLElement | Element} element target
1397
+ * @param {HTMLElement} element target
1355
1398
  * @return {number} the value in miliseconds
1356
1399
  */
1357
1400
  function getElementAnimationDuration(element) {
1358
1401
  var propertyValue = getElementStyle(element, animationName);
1359
1402
  var durationValue = getElementStyle(element, animationDuration);
1360
- var durationScale = durationValue.includes('ms') ? 1 : 1000;
1403
+ var durationScale = durationValue.includes('ms') ? /* istanbul ignore next */1 : 1000;
1361
1404
  var duration = supportAnimation && propertyValue && propertyValue !== 'none'
1362
1405
  ? parseFloat(durationValue) * durationScale : 0;
1363
1406
 
1364
- return !Number.isNaN(duration) ? duration : 0;
1407
+ return !Number.isNaN(duration) ? duration : /* istanbul ignore next */0;
1365
1408
  }
1366
1409
 
1367
1410
  /**
1368
1411
  * Utility to make sure callbacks are consistently
1369
1412
  * called when animation ends.
1370
1413
  *
1371
- * @param {HTMLElement | Element} element target
1414
+ * @param {HTMLElement} element target
1372
1415
  * @param {EventListener} handler `animationend` callback
1373
1416
  */
1374
1417
  function emulateAnimationEnd(element, handler) {
@@ -1383,6 +1426,7 @@
1383
1426
  * @param {Event} e Event object
1384
1427
  */
1385
1428
  var animationEndWrapper = function (e) {
1429
+ /* istanbul ignore else */
1386
1430
  if (e.target === element) {
1387
1431
  handler.apply(element, [e]);
1388
1432
  element.removeEventListener(animationEndEvent, animationEndWrapper);
@@ -1391,7 +1435,8 @@
1391
1435
  };
1392
1436
  element.addEventListener(animationEndEvent, animationEndWrapper);
1393
1437
  setTimeout(function () {
1394
- if (!called) { element.dispatchEvent(endEvent); }
1438
+ /* istanbul ignore next */
1439
+ if (!called) { dispatchEvent(element, endEvent); }
1395
1440
  }, duration + delay + 17);
1396
1441
  } else {
1397
1442
  handler.apply(element, [endEvent]);
@@ -1402,42 +1447,41 @@
1402
1447
  * Utility to get the computed `transitionDelay`
1403
1448
  * from Element in miliseconds.
1404
1449
  *
1405
- * @param {HTMLElement | Element} element target
1450
+ * @param {HTMLElement} element target
1406
1451
  * @return {number} the value in miliseconds
1407
1452
  */
1408
1453
  function getElementTransitionDelay$1(element) {
1409
1454
  var propertyValue = getElementStyle(element, transitionProperty$1);
1410
1455
  var delayValue = getElementStyle(element, transitionDelay$1);
1411
-
1412
- var delayScale = delayValue.includes('ms') ? 1 : 1000;
1456
+ var delayScale = delayValue.includes('ms') ? /* istanbul ignore next */1 : 1000;
1413
1457
  var duration = propertyValue && propertyValue !== 'none'
1414
1458
  ? parseFloat(delayValue) * delayScale : 0;
1415
1459
 
1416
- return !Number.isNaN(duration) ? duration : 0;
1460
+ return !Number.isNaN(duration) ? duration : /* istanbul ignore next */0;
1417
1461
  }
1418
1462
 
1419
1463
  /**
1420
1464
  * Utility to get the computed `transitionDuration`
1421
1465
  * from Element in miliseconds.
1422
1466
  *
1423
- * @param {HTMLElement | Element} element target
1467
+ * @param {HTMLElement} element target
1424
1468
  * @return {number} the value in miliseconds
1425
1469
  */
1426
1470
  function getElementTransitionDuration$1(element) {
1427
1471
  var propertyValue = getElementStyle(element, transitionProperty$1);
1428
1472
  var durationValue = getElementStyle(element, transitionDuration$1);
1429
- var durationScale = durationValue.includes('ms') ? 1 : 1000;
1473
+ var durationScale = durationValue.includes('ms') ? /* istanbul ignore next */1 : 1000;
1430
1474
  var duration = propertyValue && propertyValue !== 'none'
1431
1475
  ? parseFloat(durationValue) * durationScale : 0;
1432
1476
 
1433
- return !Number.isNaN(duration) ? duration : 0;
1477
+ return !Number.isNaN(duration) ? duration : /* istanbul ignore next */0;
1434
1478
  }
1435
1479
 
1436
1480
  /**
1437
1481
  * Utility to make sure callbacks are consistently
1438
1482
  * called when transition ends.
1439
1483
  *
1440
- * @param {HTMLElement | Element} element target
1484
+ * @param {HTMLElement} element target
1441
1485
  * @param {EventListener} handler `transitionend` callback
1442
1486
  */
1443
1487
  function emulateTransitionEnd$1(element, handler) {
@@ -1452,6 +1496,7 @@
1452
1496
  * @type {EventListener} e Event object
1453
1497
  */
1454
1498
  var transitionEndWrapper = function (e) {
1499
+ /* istanbul ignore else */
1455
1500
  if (e.target === element) {
1456
1501
  handler.apply(element, [e]);
1457
1502
  element.removeEventListener(transitionEndEvent$1, transitionEndWrapper);
@@ -1460,7 +1505,8 @@
1460
1505
  };
1461
1506
  element.addEventListener(transitionEndEvent$1, transitionEndWrapper);
1462
1507
  setTimeout(function () {
1463
- if (!called) { element.dispatchEvent(endEvent); }
1508
+ /* istanbul ignore next */
1509
+ if (!called) { dispatchEvent(element, endEvent); }
1464
1510
  }, duration + delay + 17);
1465
1511
  } else {
1466
1512
  handler.apply(element, [endEvent]);
@@ -1471,41 +1517,41 @@
1471
1517
  * Utility to get the computed `transitionDelay`
1472
1518
  * from Element in miliseconds.
1473
1519
  *
1474
- * @param {HTMLElement | Element} element target
1520
+ * @param {HTMLElement} element target
1475
1521
  * @return {number} the value in miliseconds
1476
1522
  */
1477
1523
  function getElementTransitionDelay(element) {
1478
1524
  var propertyValue = getElementStyle(element, transitionProperty);
1479
1525
  var delayValue = getElementStyle(element, transitionDelay);
1480
- var delayScale = delayValue.includes('ms') ? 1 : 1000;
1526
+ var delayScale = delayValue.includes('ms') ? /* istanbul ignore next */1 : 1000;
1481
1527
  var duration = supportTransition && propertyValue && propertyValue !== 'none'
1482
1528
  ? parseFloat(delayValue) * delayScale : 0;
1483
1529
 
1484
- return !Number.isNaN(duration) ? duration : 0;
1530
+ return !Number.isNaN(duration) ? duration : /* istanbul ignore next */0;
1485
1531
  }
1486
1532
 
1487
1533
  /**
1488
1534
  * Utility to get the computed `transitionDuration`
1489
1535
  * from Element in miliseconds.
1490
1536
  *
1491
- * @param {HTMLElement | Element} element target
1537
+ * @param {HTMLElement} element target
1492
1538
  * @return {number} the value in miliseconds
1493
1539
  */
1494
1540
  function getElementTransitionDuration(element) {
1495
1541
  var propertyValue = getElementStyle(element, transitionProperty);
1496
1542
  var durationValue = getElementStyle(element, transitionDuration);
1497
- var durationScale = durationValue.includes('ms') ? 1 : 1000;
1543
+ var durationScale = durationValue.includes('ms') ? /* istanbul ignore next */1 : 1000;
1498
1544
  var duration = supportTransition && propertyValue && propertyValue !== 'none'
1499
1545
  ? parseFloat(durationValue) * durationScale : 0;
1500
1546
 
1501
- return !Number.isNaN(duration) ? duration : 0;
1547
+ return !Number.isNaN(duration) ? duration : /* istanbul ignore next */0;
1502
1548
  }
1503
1549
 
1504
1550
  /**
1505
1551
  * Utility to make sure callbacks are consistently
1506
1552
  * called when transition ends.
1507
1553
  *
1508
- * @param {HTMLElement | Element} element target
1554
+ * @param {HTMLElement} element target
1509
1555
  * @param {EventListener} handler `transitionend` callback
1510
1556
  */
1511
1557
  function emulateTransitionEnd(element, handler) {
@@ -1520,6 +1566,7 @@
1520
1566
  * @param {Event} e Event object
1521
1567
  */
1522
1568
  var transitionEndWrapper = function (e) {
1569
+ /* istanbul ignore else */
1523
1570
  if (e.target === element) {
1524
1571
  handler.apply(element, [e]);
1525
1572
  element.removeEventListener(transitionEndEvent, transitionEndWrapper);
@@ -1528,7 +1575,8 @@
1528
1575
  };
1529
1576
  element.addEventListener(transitionEndEvent, transitionEndWrapper);
1530
1577
  setTimeout(function () {
1531
- if (!called) { element.dispatchEvent(endEvent); }
1578
+ /* istanbul ignore next */
1579
+ if (!called) { dispatchEvent(element, endEvent); }
1532
1580
  }, duration + delay + 17);
1533
1581
  } else {
1534
1582
  handler.apply(element, [endEvent]);
@@ -1552,9 +1600,8 @@
1552
1600
  /**
1553
1601
  * Utility to focus an `HTMLElement` target.
1554
1602
  *
1555
- * @param {HTMLElement | Element} element is the target
1603
+ * @param {HTMLElement} element is the target
1556
1604
  */
1557
- // @ts-ignore -- `Element`s resulted from querySelector can focus too
1558
1605
  var focus = function (element) { return element.focus(); };
1559
1606
 
1560
1607
  /** A generic function with empty body. */
@@ -1573,22 +1620,24 @@
1573
1620
  * @return {niceValue} the normalized value
1574
1621
  */
1575
1622
  function normalizeValue(value) {
1576
- if (value === 'true') { // boolean
1623
+ if (['true', true].includes(value)) { // boolean
1624
+ // if ('true' === value) { // boolean
1577
1625
  return true;
1578
1626
  }
1579
1627
 
1580
- if (value === 'false') { // boolean
1628
+ if (['false', false].includes(value)) { // boolean
1629
+ // if ('false' === value) { // boolean
1581
1630
  return false;
1582
1631
  }
1583
1632
 
1584
- if (!Number.isNaN(+value)) { // number
1585
- return +value;
1586
- }
1587
-
1588
1633
  if (value === '' || value === 'null') { // null
1589
1634
  return null;
1590
1635
  }
1591
1636
 
1637
+ if (value !== '' && !Number.isNaN(+value)) { // number
1638
+ return +value;
1639
+ }
1640
+
1592
1641
  // string / function / HTMLElement / object
1593
1642
  return value;
1594
1643
  }
@@ -1611,14 +1660,13 @@
1611
1660
  /**
1612
1661
  * Utility to normalize component options.
1613
1662
  *
1614
- * @param {HTMLElement | Element} element target
1663
+ * @param {HTMLElement} element target
1615
1664
  * @param {Record<string, any>} defaultOps component default options
1616
1665
  * @param {Record<string, any>} inputOps component instance options
1617
1666
  * @param {string=} ns component namespace
1618
1667
  * @return {Record<string, any>} normalized component options object
1619
1668
  */
1620
1669
  function normalizeOptions(element, defaultOps, inputOps, ns) {
1621
- // @ts-ignore -- our targets are always `HTMLElement`
1622
1670
  var data = Object.assign({}, element.dataset);
1623
1671
  /** @type {Record<string, any>} */
1624
1672
  var normalOps = {};
@@ -1639,6 +1687,7 @@
1639
1687
  });
1640
1688
 
1641
1689
  ObjectKeys(defaultOps).forEach(function (k) {
1690
+ /* istanbul ignore else */
1642
1691
  if (k in inputOps) {
1643
1692
  normalOps[k] = inputOps[k];
1644
1693
  } else if (k in dataOps) {
@@ -1664,13 +1713,14 @@
1664
1713
  * Returns a namespaced `CustomEvent` specific to each component.
1665
1714
  * @param {string} EventType Event.type
1666
1715
  * @param {Record<string, any>=} config Event.options | Event.properties
1667
- * @returns {SHORTER.OriginalEvent} a new namespaced event
1716
+ * @returns {SHORTY.OriginalEvent} a new namespaced event
1668
1717
  */
1669
1718
  function OriginalEvent(EventType, config) {
1670
1719
  var OriginalCustomEvent = new CustomEvent(EventType, {
1671
1720
  cancelable: true, bubbles: true,
1672
1721
  });
1673
1722
 
1723
+ /* istanbul ignore else */
1674
1724
  if (config instanceof Object) {
1675
1725
  ObjectAssign(OriginalCustomEvent, config);
1676
1726
  }
@@ -1687,26 +1737,37 @@
1687
1737
  * A global namespace for most scroll event listeners in legacy browsers.
1688
1738
  * @type {Partial<AddEventListenerOptions> | boolean}
1689
1739
  */
1690
- var passiveHandler = supportPassive ? { passive: true } : false;
1740
+ var passiveHandler = supportPassive ? { passive: true }
1741
+ : /* istanbul ignore next */false;
1691
1742
 
1692
1743
  /**
1693
1744
  * Utility to force re-paint of an `HTMLElement` target.
1694
1745
  *
1695
- * @param {HTMLElement | Element} element is the target
1746
+ * @param {HTMLElement} element is the target
1696
1747
  * @return {number} the `Element.offsetHeight` value
1697
1748
  */
1698
- // @ts-ignore
1699
1749
  var reflow = function (element) { return element.offsetHeight; };
1700
1750
 
1701
1751
  /**
1702
1752
  * Shortcut for multiple uses of `HTMLElement.style.propertyName` method.
1703
- * @param {HTMLElement | Element} element target element
1753
+ * @param {HTMLElement} element target element
1704
1754
  * @param {Partial<CSSStyleDeclaration>} styles attribute value
1705
1755
  */
1706
- // @ts-ignore
1707
- var setElementStyle = function (element, styles) { ObjectAssign(element.style, styles); };
1756
+ var setElementStyle = function (element, styles) {
1757
+ ObjectEntries(styles).forEach(function (ref) {
1758
+ var key = ref[0];
1759
+ var value = ref[1];
1760
+
1761
+ if (key.includes('--')) {
1762
+ element.style.setProperty(key, value);
1763
+ } else {
1764
+ var propObject = {}; propObject[key] = value;
1765
+ ObjectAssign(element.style, propObject);
1766
+ }
1767
+ });
1768
+ };
1708
1769
 
1709
- /** @type {Map<HTMLElement | Element, any>} */
1770
+ /** @type {Map<HTMLElement, any>} */
1710
1771
  var TimeCache = new Map();
1711
1772
  /**
1712
1773
  * An interface for one or more `TimerHandler`s per `Element`.
@@ -1715,17 +1776,17 @@
1715
1776
  var Timer = {
1716
1777
  /**
1717
1778
  * Sets a new timeout timer for an element, or element -> key association.
1718
- * @param {HTMLElement | Element | string} target target element
1779
+ * @param {HTMLElement} element target element
1719
1780
  * @param {ReturnType<TimerHandler>} callback the callback
1720
1781
  * @param {number} delay the execution delay
1721
1782
  * @param {string=} key a unique key
1722
1783
  */
1723
- set: function (target, callback, delay, key) {
1724
- var element = querySelector(target);
1725
-
1726
- if (!element) { return; }
1784
+ set: function (element, callback, delay, key) {
1785
+ if (!isHTMLElement(element)) { return; }
1727
1786
 
1787
+ /* istanbul ignore else */
1728
1788
  if (key && key.length) {
1789
+ /* istanbul ignore else */
1729
1790
  if (!TimeCache.has(element)) {
1730
1791
  TimeCache.set(element, new Map());
1731
1792
  }
@@ -1738,38 +1799,35 @@
1738
1799
 
1739
1800
  /**
1740
1801
  * Returns the timer associated with the target.
1741
- * @param {HTMLElement | Element | string} target target element
1802
+ * @param {HTMLElement} element target element
1742
1803
  * @param {string=} key a unique
1743
1804
  * @returns {number?} the timer
1744
1805
  */
1745
- get: function (target, key) {
1746
- var element = querySelector(target);
1747
-
1748
- if (!element) { return null; }
1806
+ get: function (element, key) {
1807
+ if (!isHTMLElement(element)) { return null; }
1749
1808
  var keyTimers = TimeCache.get(element);
1750
1809
 
1751
1810
  if (key && key.length && keyTimers && keyTimers.get) {
1752
- return keyTimers.get(key) || null;
1811
+ return keyTimers.get(key) || /* istanbul ignore next */null;
1753
1812
  }
1754
1813
  return keyTimers || null;
1755
1814
  },
1756
1815
 
1757
1816
  /**
1758
1817
  * Clears the element's timer.
1759
- * @param {HTMLElement | Element | string} target target element
1818
+ * @param {HTMLElement} element target element
1760
1819
  * @param {string=} key a unique key
1761
1820
  */
1762
- clear: function (target, key) {
1763
- var element = querySelector(target);
1764
-
1765
- if (!element) { return; }
1821
+ clear: function (element, key) {
1822
+ if (!isHTMLElement(element)) { return; }
1766
1823
 
1767
1824
  if (key && key.length) {
1768
1825
  var keyTimers = TimeCache.get(element);
1769
-
1826
+ /* istanbul ignore else */
1770
1827
  if (keyTimers && keyTimers.get) {
1771
1828
  clearTimeout(keyTimers.get(key));
1772
1829
  keyTimers.delete(key);
1830
+ /* istanbul ignore else */
1773
1831
  if (keyTimers.size === 0) {
1774
1832
  TimeCache.delete(element);
1775
1833
  }
@@ -1789,26 +1847,14 @@
1789
1847
  */
1790
1848
  var toUpperCase = function (source) { return source.toUpperCase(); };
1791
1849
 
1792
- /**
1793
- * Utility to wrap a callback in a try() catch(e)
1794
- *
1795
- * @param {Function} fn callback
1796
- * @param {string} origin callback context description
1797
- */
1798
- function tryWrapper(fn, origin) {
1799
- try { fn(); } catch (e) {
1800
- throw TypeError((origin + " " + e));
1801
- }
1802
- }
1803
-
1804
1850
  /**
1805
1851
  * Returns the bounding client rect of a target `HTMLElement`.
1806
1852
  *
1807
1853
  * @see https://github.com/floating-ui/floating-ui
1808
1854
  *
1809
- * @param {HTMLElement | Element} element event.target
1855
+ * @param {HTMLElement} element event.target
1810
1856
  * @param {boolean=} includeScale when *true*, the target scale is also computed
1811
- * @returns {SHORTER.BoundingClientRect} the bounding client rect object
1857
+ * @returns {SHORTY.BoundingClientRect} the bounding client rect object
1812
1858
  */
1813
1859
  function getBoundingClientRect(element, includeScale) {
1814
1860
  var ref = element.getBoundingClientRect();
@@ -1821,11 +1867,13 @@
1821
1867
  var scaleX = 1;
1822
1868
  var scaleY = 1;
1823
1869
 
1824
- if (includeScale && element instanceof HTMLElement) {
1870
+ if (includeScale && isHTMLElement(element)) {
1825
1871
  var offsetWidth = element.offsetWidth;
1826
1872
  var offsetHeight = element.offsetHeight;
1827
- scaleX = offsetWidth > 0 ? Math.round(width) / offsetWidth || 1 : 1;
1828
- scaleY = offsetHeight > 0 ? Math.round(height) / offsetHeight || 1 : 1;
1873
+ scaleX = offsetWidth > 0 ? Math.round(width) / offsetWidth
1874
+ : /* istanbul ignore next */1;
1875
+ scaleY = offsetHeight > 0 ? Math.round(height) / offsetHeight
1876
+ : /* istanbul ignore next */1;
1829
1877
  }
1830
1878
 
1831
1879
  return {
@@ -1843,8 +1891,8 @@
1843
1891
  /**
1844
1892
  * Returns the `document.body` or the `<body>` element.
1845
1893
  *
1846
- * @param {(Node | HTMLElement | Element | globalThis)=} node
1847
- * @returns {HTMLElement | HTMLBodyElement}
1894
+ * @param {(ParentNode | Window)=} node
1895
+ * @returns {HTMLBodyElement}
1848
1896
  */
1849
1897
  function getDocumentBody(node) {
1850
1898
  return getDocument(node).body;
@@ -1853,8 +1901,8 @@
1853
1901
  /**
1854
1902
  * Returns the `document.documentElement` or the `<html>` element.
1855
1903
  *
1856
- * @param {(Node | HTMLElement | Element | globalThis)=} node
1857
- * @returns {HTMLElement | HTMLHtmlElement}
1904
+ * @param {(ParentNode | Window)=} node
1905
+ * @returns {HTMLHtmlElement}
1858
1906
  */
1859
1907
  function getDocumentElement(node) {
1860
1908
  return getDocument(node).documentElement;
@@ -1863,8 +1911,8 @@
1863
1911
  /**
1864
1912
  * Returns the `document.head` or the `<head>` element.
1865
1913
  *
1866
- * @param {(Node | HTMLElement | Element | globalThis)=} node
1867
- * @returns {HTMLElement | HTMLHeadElement}
1914
+ * @param {(ParentNode | Window)=} node
1915
+ * @returns {HTMLHeadElement}
1868
1916
  */
1869
1917
  function getDocumentHead(node) {
1870
1918
  return getDocument(node).head;
@@ -1876,7 +1924,7 @@
1876
1924
  *
1877
1925
  * @see https://github.com/floating-ui/floating-ui
1878
1926
  *
1879
- * @param {HTMLElement | Element | Window} element target node / element
1927
+ * @param {HTMLElement | Window} element target node / element
1880
1928
  * @returns {{x: number, y: number}} the scroll tuple
1881
1929
  */
1882
1930
  function getNodeScroll(element) {
@@ -1887,44 +1935,21 @@
1887
1935
  return { x: x, y: y };
1888
1936
  }
1889
1937
 
1890
- /**
1891
- * Returns the `Window` object of a target node.
1892
- * @see https://github.com/floating-ui/floating-ui
1893
- *
1894
- * @param {(Node | HTMLElement | Element | Window)=} node target node
1895
- * @returns {globalThis}
1896
- */
1897
- function getWindow(node) {
1898
- if (node == null) {
1899
- return window;
1900
- }
1901
-
1902
- if (!(node instanceof Window)) {
1903
- var ownerDocument = node.ownerDocument;
1904
- return ownerDocument ? ownerDocument.defaultView || window : window;
1905
- }
1906
-
1907
- // @ts-ignore
1908
- return node;
1909
- }
1910
-
1911
1938
  /**
1912
1939
  * Check if target is a `ShadowRoot`.
1913
1940
  *
1914
1941
  * @param {any} element target
1915
1942
  * @returns {boolean} the query result
1916
1943
  */
1917
- var isShadowRoot = function (element) {
1918
- var OwnElement = getWindow(element).ShadowRoot;
1919
- return element instanceof OwnElement || element instanceof ShadowRoot;
1920
- };
1944
+ var isShadowRoot = function (element) { return (element && element.constructor.name === 'ShadowRoot')
1945
+ || false; };
1921
1946
 
1922
1947
  /**
1923
1948
  * Returns the `parentNode` also going through `ShadowRoot`.
1924
1949
  * @see https://github.com/floating-ui/floating-ui
1925
1950
  *
1926
- * @param {Node | HTMLElement | Element} node the target node
1927
- * @returns {Node | HTMLElement | Element} the apropriate parent node
1951
+ * @param {Node} node the target node
1952
+ * @returns {Node} the apropriate parent node
1928
1953
  */
1929
1954
  function getParentNode(node) {
1930
1955
  if (node.nodeName === 'HTML') {
@@ -1933,10 +1958,9 @@
1933
1958
 
1934
1959
  // this is a quicker (but less type safe) way to save quite some bytes from the bundle
1935
1960
  return (
1936
- // @ts-ignore
1937
1961
  node.assignedSlot // step into the shadow DOM of the parent of a slotted node
1938
- || node.parentNode // @ts-ignore DOM Element detected
1939
- || (isShadowRoot(node) ? node.host : null) // ShadowRoot detected
1962
+ || node.parentNode // DOM Element detected
1963
+ || (isShadowRoot(node) && node.host) // ShadowRoot detected
1940
1964
  || getDocumentElement(node) // fallback
1941
1965
  );
1942
1966
  }
@@ -1949,6 +1973,7 @@
1949
1973
  * @returns {boolean} the query result
1950
1974
  */
1951
1975
  function isScaledElement(element) {
1976
+ if (!element || !isHTMLElement(element)) { return false; }
1952
1977
  var ref = getBoundingClientRect(element);
1953
1978
  var width = ref.width;
1954
1979
  var height = ref.height;
@@ -1962,16 +1987,17 @@
1962
1987
  * Returns the rect relative to an offset parent.
1963
1988
  * @see https://github.com/floating-ui/floating-ui
1964
1989
  *
1965
- * @param {HTMLElement | Element} element target
1966
- * @param {HTMLElement | Element | Window} offsetParent the container / offset parent
1967
- * @param {{x: number, y: number}} scroll
1968
- * @returns {SHORTER.OffsetRect}
1990
+ * @param {HTMLElement} element target
1991
+ * @param {ParentNode | Window} offsetParent the container / offset parent
1992
+ * @param {{x: number, y: number}} scroll the offsetParent scroll position
1993
+ * @returns {SHORTY.OffsetRect}
1969
1994
  */
1970
1995
  function getRectRelativeToOffsetParent(element, offsetParent, scroll) {
1971
- var isParentAnElement = offsetParent instanceof HTMLElement;
1996
+ var isParentAnElement = isHTMLElement(offsetParent);
1972
1997
  var rect = getBoundingClientRect(element, isParentAnElement && isScaledElement(offsetParent));
1973
1998
  var offsets = { x: 0, y: 0 };
1974
1999
 
2000
+ /* istanbul ignore next */
1975
2001
  if (isParentAnElement) {
1976
2002
  var offsetRect = getBoundingClientRect(offsetParent, true);
1977
2003
  offsets.x = offsetRect.x + offsetParent.clientLeft;
@@ -1993,7 +2019,7 @@
1993
2019
  /**
1994
2020
  * Returns a unique identifier for popover, tooltip, scrollspy.
1995
2021
  *
1996
- * @param {HTMLElement | Element} element target element
2022
+ * @param {HTMLElement} element target element
1997
2023
  * @param {string=} key predefined key
1998
2024
  * @returns {number} an existing or new unique ID
1999
2025
  */
@@ -2022,20 +2048,39 @@
2022
2048
  }
2023
2049
 
2024
2050
  /**
2025
- * Shortcut for `Array.isArray()` static method.
2051
+ * Returns the `Window` object of a target node.
2052
+ * @see https://github.com/floating-ui/floating-ui
2026
2053
  *
2027
- * @param {any} arr array-like iterable object
2028
- * @returns {boolean} the query result
2054
+ * @param {(Node | Window)=} node target node
2055
+ * @returns {Window} the `Window` object
2029
2056
  */
2030
- var isArray = function (arr) { return Array.isArray(arr); };
2057
+ function getWindow(node) {
2058
+ // node is undefined | NULL
2059
+ if (!node) {
2060
+ return window;
2061
+ }
2062
+
2063
+ // node instanceof Document
2064
+ if (isDocument(node)) {
2065
+ return node.defaultView;
2066
+ }
2067
+
2068
+ // node instanceof Node
2069
+ if (isNode(node)) {
2070
+ return node.ownerDocument.defaultView;
2071
+ }
2072
+
2073
+ // node is instanceof Window
2074
+ return node;
2075
+ }
2031
2076
 
2032
2077
  /**
2033
- * Checks if an object is a `Document`.
2078
+ * Shortcut for `Array.isArray()` static method.
2034
2079
  *
2035
- * @param {any} element the target object
2080
+ * @param {any} arr array-like iterable object
2036
2081
  * @returns {boolean} the query result
2037
2082
  */
2038
- var isDocument = function (element) { return element instanceof Document; };
2083
+ var isArray = function (arr) { return Array.isArray(arr); };
2039
2084
 
2040
2085
  /**
2041
2086
  * Checks if an object is a `CustomElement`.
@@ -2043,30 +2088,44 @@
2043
2088
  * @param {any} element the target object
2044
2089
  * @returns {boolean} the query result
2045
2090
  */
2046
- var isCustomElement = function (element) { return element && !!element.shadowRoot; };
2091
+ var isCustomElement = function (element) { return (element && !!element.shadowRoot) || false; };
2047
2092
 
2048
2093
  /**
2049
2094
  * Checks if an object is an `Element`.
2095
+ * @see https://dom.spec.whatwg.org/#node
2096
+ * ELEMENT_NODE = 1;
2097
+ * ATTRIBUTE_NODE = 2;
2098
+ * TEXT_NODE = 3;
2099
+ * CDATA_SECTION_NODE = 4;
2100
+ * ENTITY_REFERENCE_NODE = 5; // legacy
2101
+ * ENTITY_NODE = 6; // legacy
2102
+ * PROCESSING_INSTRUCTION_NODE = 7;
2103
+ * COMMENT_NODE = 8;
2104
+ * DOCUMENT_NODE = 9;
2105
+ * DOCUMENT_TYPE_NODE = 10;
2106
+ * DOCUMENT_FRAGMENT_NODE = 11;
2050
2107
  *
2051
2108
  * @param {any} element the target object
2052
2109
  * @returns {boolean} the query result
2053
2110
  */
2054
- var isElement = function (element) { return element instanceof Element; };
2111
+ var isElement = function (element) { return (element && [1, 2, 3, 4, 5, 6, 7, 8]
2112
+ .some(function (x) { return element.nodeType === x; })) || false; };
2055
2113
 
2056
2114
  /**
2057
2115
  * Utility to determine if an `HTMLElement`
2058
2116
  * is partially visible in viewport.
2059
2117
  *
2060
- * @param {HTMLElement | Element} element target
2118
+ * @param {HTMLElement} element target
2061
2119
  * @return {boolean} the query result
2062
2120
  */
2063
2121
  var isElementInScrollRange = function (element) {
2122
+ if (!element || !isNode(element)) { return false; }
2123
+
2064
2124
  var ref = getBoundingClientRect(element);
2065
2125
  var top = ref.top;
2066
2126
  var bottom = ref.bottom;
2067
2127
  var ref$1 = getDocumentElement(element);
2068
2128
  var clientHeight = ref$1.clientHeight;
2069
- // checks bottom && top
2070
2129
  return top <= clientHeight && bottom >= 0;
2071
2130
  };
2072
2131
 
@@ -2074,18 +2133,21 @@
2074
2133
  * Utility to determine if an `HTMLElement`
2075
2134
  * is fully visible in the viewport.
2076
2135
  *
2077
- * @param {HTMLElement | Element} element target
2136
+ * @param {HTMLElement} element target
2078
2137
  * @return {boolean} the query result
2079
2138
  */
2080
2139
  var isElementInViewport = function (element) {
2081
- var ref = getBoundingClientRect(element, true);
2082
- var top = ref.top;
2083
- var left = ref.left;
2084
- var bottom = ref.bottom;
2085
- var right = ref.right;
2086
- var ref$1 = getDocumentElement(element);
2087
- var clientWidth = ref$1.clientWidth;
2088
- var clientHeight = ref$1.clientHeight;
2140
+ if (!element || !isNode(element)) { return false; }
2141
+
2142
+ var ref = getDocumentElement(element);
2143
+ var clientWidth = ref.clientWidth;
2144
+ var clientHeight = ref.clientHeight;
2145
+ var ref$1 = getBoundingClientRect(element, true);
2146
+ var top = ref$1.top;
2147
+ var left = ref$1.left;
2148
+ var bottom = ref$1.bottom;
2149
+ var right = ref$1.right;
2150
+
2089
2151
  return (
2090
2152
  top >= 0 && left >= 0
2091
2153
  && bottom <= clientHeight
@@ -2100,30 +2162,30 @@
2100
2162
  * @returns {boolean} the query result
2101
2163
  */
2102
2164
  var isElementsArray = function (object) { return Array.isArray(object)
2103
- && object.every(function (el) { return [HTMLElement, Element].some(function (x) { return el instanceof x; }); }); };
2165
+ && object.every(isHTMLElement); };
2104
2166
 
2105
2167
  /**
2106
- * Checks if an object is an `HTMLCollection`.
2168
+ * Checks if an object is a `Function`.
2107
2169
  *
2108
- * @param {any} object the target object
2170
+ * @param {any} fn the target object
2109
2171
  * @returns {boolean} the query result
2110
2172
  */
2111
- var isHTMLCollection = function (object) { return object instanceof HTMLCollection; };
2173
+ var isFunction = function (fn) { return (fn && fn.constructor.name === 'Function') || false; };
2112
2174
 
2113
2175
  /**
2114
- * Checks if an element is an `HTMLElement`.
2176
+ * Checks if an object is an `HTMLCollection`.
2115
2177
  *
2116
- * @param {any} element the target object
2178
+ * @param {any} object the target object
2117
2179
  * @returns {boolean} the query result
2118
2180
  */
2119
- var isHTMLElement = function (element) { return element instanceof HTMLElement; };
2181
+ var isHTMLCollection = function (object) { return (object && object.constructor.name === 'HTMLCollection') || false; };
2120
2182
 
2121
2183
  /**
2122
2184
  * Check if a target element is an `<img>`.
2123
2185
  * @param {any} element the target element
2124
2186
  * @returns {boolean} the query result
2125
2187
  */
2126
- var isHTMLImageElement = function (element) { return element instanceof HTMLImageElement; };
2188
+ var isHTMLImageElement = function (element) { return (element && element.tagName === 'IMG') || false; };
2127
2189
 
2128
2190
  /**
2129
2191
  * Checks if an element is an `<svg>` (or any type of SVG element),
@@ -2133,37 +2195,40 @@
2133
2195
  * @param {any} element the target element
2134
2196
  * @returns {boolean} the query result
2135
2197
  */
2136
- var isMedia = function (element) { return element
2137
- && [SVGElement, HTMLImageElement, HTMLVideoElement]
2138
- .some(function (mediaType) { return element instanceof mediaType; }); };
2198
+
2199
+ var isMedia = function (element) { return (
2200
+ element
2201
+ && element.nodeType === 1
2202
+ && ['SVG', 'Image', 'Video'].some(function (s) { return element.constructor.name.includes(s); })) || false; };
2139
2203
 
2140
2204
  /**
2141
- * Checks if an object is a `Node`.
2205
+ * Checks if an object is a `NodeList`.
2206
+ * => equivalent to `object instanceof NodeList`
2142
2207
  *
2143
- * @param {any} node the target object
2208
+ * @param {any} object the target object
2144
2209
  * @returns {boolean} the query result
2145
2210
  */
2146
- var isNode = function (node) { return node instanceof Node; };
2211
+ var isNodeList = function (object) { return (object && object.constructor.name === 'NodeList') || false; };
2147
2212
 
2148
2213
  /**
2149
- * Checks if an object is a `NodeList`.
2214
+ * Shortcut for `typeof SOMETHING === "number"`.
2150
2215
  *
2151
- * @param {any} object the target object
2216
+ * @param {any} num input value
2152
2217
  * @returns {boolean} the query result
2153
2218
  */
2154
- var isNodeList = function (object) { return object instanceof NodeList; };
2219
+ var isNumber = function (num) { return typeof num === 'number'; };
2155
2220
 
2156
2221
  /**
2157
2222
  * Checks if a page is Right To Left.
2158
- * @param {(HTMLElement | Element)=} node the target
2223
+ * @param {HTMLElement=} node the target
2159
2224
  * @returns {boolean} the query result
2160
2225
  */
2161
2226
  var isRTL = function (node) { return getDocumentElement(node).dir === 'rtl'; };
2162
2227
 
2163
2228
  /**
2164
- * Shortcut for `typeof SOMETHING === string` static method.
2229
+ * Shortcut for `typeof SOMETHING === "string"`.
2165
2230
  *
2166
- * @param {any} str array-like iterable object
2231
+ * @param {any} str input value
2167
2232
  * @returns {boolean} the query result
2168
2233
  */
2169
2234
  var isString = function (str) { return typeof str === 'string'; };
@@ -2173,24 +2238,19 @@
2173
2238
  * @param {any} element the target element
2174
2239
  * @returns {boolean} the query result
2175
2240
  */
2176
- var isSVGElement = function (element) { return element instanceof SVGElement; };
2241
+ var isSVGElement = function (element) { return (element && element instanceof getWindow(element).SVGElement)
2242
+ || false; };
2177
2243
 
2178
2244
  /**
2179
2245
  * Check if a target element is a `<table>`, `<td>` or `<th>`.
2180
- * @param {any} element the target element
2181
- * @returns {boolean} the query result
2182
- */
2183
- var isTableElement = function (element) { return ['TABLE', 'TD', 'TH'].includes(element.tagName); };
2184
-
2185
- /**
2186
- * Check if a target node is `window`.
2246
+ * This specific check is important for determining
2247
+ * the `offsetParent` of a given element.
2187
2248
  *
2188
- * @param {any} node the target node
2249
+ * @param {any} element the target element
2189
2250
  * @returns {boolean} the query result
2190
2251
  */
2191
- function isWindow(node) {
2192
- return node instanceof Window;
2193
- }
2252
+ var isTableElement = function (element) { return (element && ['TABLE', 'TD', 'TH'].includes(element.tagName))
2253
+ || false; };
2194
2254
 
2195
2255
  /**
2196
2256
  * Shortcut for `HTMLElement.closest` method which also works
@@ -2199,68 +2259,82 @@
2199
2259
  *
2200
2260
  * @see https://stackoverflow.com/q/54520554/803358
2201
2261
  *
2202
- * @param {HTMLElement | Element} element Element to look into
2262
+ * @param {HTMLElement} element Element to look into
2203
2263
  * @param {string} selector the selector name
2204
- * @return {(HTMLElement | Element)?} the query result
2264
+ * @return {HTMLElement?} the query result
2205
2265
  */
2206
2266
  function closest(element, selector) {
2207
2267
  return element ? (element.closest(selector)
2208
- // @ts-ignore -- break out of `ShadowRoot`
2268
+ // break out of `ShadowRoot`
2209
2269
  || closest(element.getRootNode().host, selector)) : null;
2210
2270
  }
2211
2271
 
2272
+ /**
2273
+ * Utility to check if target is typeof `HTMLElement`, `Element`, `Node`
2274
+ * or find one that matches a selector.
2275
+ *
2276
+ * @param {Node | string} selector the input selector or target element
2277
+ * @param {ParentNode=} parent optional node to look into
2278
+ * @return {HTMLElement?} the `HTMLElement` or `querySelector` result
2279
+ */
2280
+ function querySelector(selector, parent) {
2281
+ if (isNode(selector)) {
2282
+ return selector;
2283
+ }
2284
+ var lookUp = isNode(parent) ? parent : getDocument();
2285
+
2286
+ return lookUp.querySelector(selector);
2287
+ }
2288
+
2212
2289
  /**
2213
2290
  * Shortcut for `HTMLElement.getElementsByTagName` method. Some `Node` elements
2214
2291
  * like `ShadowRoot` do not support `getElementsByTagName`.
2215
2292
  *
2216
2293
  * @param {string} selector the tag name
2217
- * @param {(HTMLElement | Element | Document)=} parent optional Element to look into
2218
- * @return {HTMLCollectionOf<HTMLElement | Element>} the 'HTMLCollection'
2294
+ * @param {ParentNode=} parent optional Element to look into
2295
+ * @return {HTMLCollectionOf<HTMLElement>} the 'HTMLCollection'
2219
2296
  */
2220
2297
  function getElementsByTagName(selector, parent) {
2221
- var lookUp = typeof parent !== 'object' ? getDocument() : parent;
2298
+ var lookUp = isNode(parent) ? parent : getDocument();
2222
2299
  return lookUp.getElementsByTagName(selector);
2223
2300
  }
2224
2301
 
2225
- /**
2226
- * An `HTMLCollection` with all document elements,
2227
- * which is the equivalent of `document.all`.
2228
- */
2229
- var documentAll = getElementsByTagName('*');
2230
-
2231
2302
  /**
2232
2303
  * Returns an `Array` of `Node` elements that are registered as
2233
2304
  * `CustomElement`.
2234
2305
  * @see https://stackoverflow.com/questions/27334365/how-to-get-list-of-registered-custom-elements
2235
2306
  *
2236
- * @param {(HTMLElement | Element | Node | Document)=} parent parent to look into
2237
- * @returns {Array<HTMLElement | Element>} the query result
2307
+ * @param {ParentNode=} parent parent to look into
2308
+ * @returns {Array<HTMLElement>} the query result
2238
2309
  */
2239
2310
  function getCustomElements(parent) {
2240
- var collection = parent && typeof parent === 'object'
2241
- ? getElementsByTagName('*', parent) : documentAll;
2311
+ var collection = getElementsByTagName('*', parent);
2312
+
2242
2313
  return [].concat( collection ).filter(isCustomElement);
2243
2314
  }
2244
2315
 
2245
2316
  /**
2246
2317
  * Returns an `Element` that matches the id in the document.
2318
+ * Within multiple <iframe> elements, a `parent` parameter
2319
+ * would decisively locate the correct element.
2247
2320
  *
2248
2321
  * @param {string} id
2249
- * @returns {(HTMLElement | Element)?}
2322
+ * @param {ParentNode=} context
2323
+ * @returns {HTMLElement?}
2250
2324
  */
2251
- function getElementById(id) {
2252
- return getDocument().getElementById(id);
2325
+ function getElementById(id, context) {
2326
+ return getDocument(context).getElementById(id);
2253
2327
  }
2254
2328
 
2255
2329
  /**
2256
2330
  * A shortcut for `(document|Element).querySelectorAll`.
2257
2331
  *
2258
2332
  * @param {string} selector the input selector
2259
- * @param {(HTMLElement | Element | Document | Node)=} parent optional node to look into
2260
- * @return {NodeListOf<HTMLElement | Element>} the query result
2333
+ * @param {ParentNode=} parent optional node to look into
2334
+ * @return {NodeListOf<HTMLElement>} the query result
2261
2335
  */
2262
2336
  function querySelectorAll(selector, parent) {
2263
- var lookUp = typeof parent !== 'object' ? getDocument() : parent;
2337
+ var lookUp = isNode(parent) ? parent : getDocument();
2264
2338
  return lookUp.querySelectorAll(selector);
2265
2339
  }
2266
2340
 
@@ -2269,18 +2343,18 @@
2269
2343
  * like `ShadowRoot` do not support `getElementsByClassName`.
2270
2344
  *
2271
2345
  * @param {string} selector the class name
2272
- * @param {(HTMLElement | Element | Document)=} parent optional Element to look into
2273
- * @return {HTMLCollectionOf<HTMLElement | Element>} the 'HTMLCollection'
2346
+ * @param {ParentNode=} parent optional Element to look into
2347
+ * @return {HTMLCollectionOf<HTMLElement>} the 'HTMLCollection'
2274
2348
  */
2275
2349
  function getElementsByClassName(selector, parent) {
2276
- var lookUp = typeof parent !== 'object' ? getDocument() : parent;
2350
+ var lookUp = isNode(parent) ? parent : getDocument();
2277
2351
  return lookUp.getElementsByClassName(selector);
2278
2352
  }
2279
2353
 
2280
2354
  /**
2281
2355
  * Check if element matches a CSS selector.
2282
2356
  *
2283
- * @param {HTMLElement | Element} target
2357
+ * @param {HTMLElement} target
2284
2358
  * @param {string} selector
2285
2359
  * @returns {boolean}
2286
2360
  */
@@ -2288,15 +2362,15 @@
2288
2362
  return target.matches(selector);
2289
2363
  }
2290
2364
 
2291
- // @ts-nocheck
2292
2365
  var ElementProto = Element.prototype;
2366
+
2293
2367
  var matchesFn = ElementProto.matches
2294
- || ElementProto.matchesSelector
2295
- || ElementProto.webkitMatchesSelector
2296
- || ElementProto.mozMatchesSelector
2297
- || ElementProto.msMatchesSelector
2298
- || ElementProto.oMatchesSelector
2299
- || function matchesNotSupported() {
2368
+ || /* istanbul ignore next */ ElementProto.matchesSelector
2369
+ || /* istanbul ignore next */ ElementProto.webkitMatchesSelector
2370
+ || /* istanbul ignore next */ ElementProto.mozMatchesSelector
2371
+ || /* istanbul ignore next */ ElementProto.msMatchesSelector
2372
+ || /* istanbul ignore next */ ElementProto.oMatchesSelector
2373
+ || /* istanbul ignore next */ function matchesNotSupported() {
2300
2374
  return false;
2301
2375
  };
2302
2376
 
@@ -2304,7 +2378,7 @@
2304
2378
  * Check if element matches a CSS selector,
2305
2379
  * supporting a range of legacy browsers.
2306
2380
  *
2307
- * @param {HTMLElement | Element} target
2381
+ * @param {HTMLElement} target
2308
2382
  * @param {string} selector
2309
2383
  * @returns {boolean}
2310
2384
  */
@@ -2312,9 +2386,7 @@
2312
2386
  return matchesFn.call(target, selector);
2313
2387
  }
2314
2388
 
2315
- var version = "1.0.1";
2316
-
2317
- // @ts-ignore
2389
+ var version = "1.0.2";
2318
2390
 
2319
2391
  /**
2320
2392
  * A global namespace for library version.
@@ -2322,9 +2394,9 @@
2322
2394
  */
2323
2395
  var Version = version;
2324
2396
 
2325
- // strings
2397
+ /** @typedef {import('../types/index')} */
2326
2398
 
2327
- var SHORTER = {
2399
+ var SHORTY = {
2328
2400
  ariaChecked: ariaChecked,
2329
2401
  ariaDescription: ariaDescription,
2330
2402
  ariaDescribedBy: ariaDescribedBy,
@@ -2490,6 +2562,7 @@
2490
2562
  isCustomElement: isCustomElement,
2491
2563
  isElement: isElement,
2492
2564
  isNode: isNode,
2565
+ isNumber: isNumber,
2493
2566
  isHTMLElement: isHTMLElement,
2494
2567
  isHTMLImageElement: isHTMLImageElement,
2495
2568
  isSVGElement: isSVGElement,
@@ -2500,11 +2573,11 @@
2500
2573
  isShadowRoot: isShadowRoot,
2501
2574
  isDocument: isDocument,
2502
2575
  isElementsArray: isElementsArray,
2576
+ isFunction: isFunction,
2503
2577
  isWindow: isWindow,
2504
2578
  isMedia: isMedia,
2505
2579
  isRTL: isRTL,
2506
2580
  closest: closest,
2507
- documentAll: documentAll,
2508
2581
  querySelector: querySelector,
2509
2582
  getCustomElements: getCustomElements,
2510
2583
  getElementById: getElementById,
@@ -2515,7 +2588,6 @@
2515
2588
  matchesLegacy: matches,
2516
2589
  normalizeValue: normalizeValue,
2517
2590
  normalizeOptions: normalizeOptions,
2518
- tryWrapper: tryWrapper,
2519
2591
  reflow: reflow,
2520
2592
  noop: noop,
2521
2593
  focus: focus,
@@ -2524,6 +2596,7 @@
2524
2596
  Float32ArrayFrom: Float32ArrayFrom,
2525
2597
  Float64ArrayFrom: Float64ArrayFrom,
2526
2598
  ObjectAssign: ObjectAssign,
2599
+ ObjectEntries: ObjectEntries,
2527
2600
  ObjectKeys: ObjectKeys,
2528
2601
  ObjectValues: ObjectValues,
2529
2602
  OriginalEvent: OriginalEvent,
@@ -2545,6 +2618,6 @@
2545
2618
  Version: Version,
2546
2619
  };
2547
2620
 
2548
- return SHORTER;
2621
+ return SHORTY;
2549
2622
 
2550
2623
  }));