@thednp/shorty 1.0.0 → 1.0.3
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/README.md +14 -8
- package/dist/shorty.esm.js +388 -329
- package/dist/shorty.esm.min.js +2 -2
- package/dist/shorty.js +401 -336
- package/dist/shorty.min.js +2 -2
- package/package.json +12 -3
- package/src/attr/getAttribute.js +1 -1
- package/src/attr/getAttributeNS.js +1 -1
- package/src/attr/hasAttribute.js +1 -1
- package/src/attr/hasAttributeNS.js +1 -1
- package/src/attr/removeAttribute.js +1 -1
- package/src/attr/removeAttributeNS.js +1 -1
- package/src/attr/setAttribute.js +1 -1
- package/src/attr/setAttributeNS.js +1 -1
- package/src/boolean/isApple.js +2 -2
- package/src/boolean/isFirefox.js +2 -1
- package/src/boolean/isMobile.js +2 -2
- package/src/boolean/support3DTransform.js +2 -1
- package/src/boolean/supportAnimation.js +2 -1
- package/src/boolean/supportPassive.js +2 -1
- package/src/boolean/supportTouch.js +2 -1
- package/src/boolean/supportTransform.js +2 -1
- package/src/boolean/supportTransition.js +2 -1
- package/src/class/addClass.js +1 -1
- package/src/class/hasClass.js +1 -1
- package/src/class/removeClass.js +1 -1
- package/src/event/off.js +2 -6
- package/src/event/on.js +2 -6
- package/src/event/one.js +3 -6
- package/src/get/getBoundingClientRect.js +9 -5
- package/src/get/getDocument.js +12 -3
- package/src/get/getDocumentBody.js +2 -2
- package/src/get/getDocumentElement.js +2 -2
- package/src/get/getDocumentHead.js +2 -2
- package/src/get/getElementAnimationDelay.js +3 -3
- package/src/get/getElementAnimationDelayLegacy.js +3 -3
- package/src/get/getElementAnimationDuration.js +3 -3
- package/src/get/getElementAnimationDurationLegacy.js +3 -3
- package/src/get/getElementStyle.js +5 -3
- package/src/get/getElementTransitionDelay.js +3 -4
- package/src/get/getElementTransitionDelayLegacy.js +3 -3
- package/src/get/getElementTransitionDuration.js +3 -3
- package/src/get/getElementTransitionDurationLegacy.js +3 -3
- package/src/get/getNodeScroll.js +1 -1
- package/src/get/getParentNode.js +4 -5
- package/src/get/getRectRelativeToOffsetParent.js +7 -5
- package/src/get/getUID.js +1 -1
- package/src/get/getWindow.js +12 -12
- package/src/index.js +12 -10
- package/src/is/isArray.js +0 -1
- package/src/is/isCustomElement.js +1 -1
- package/src/is/isDocument.js +3 -2
- package/src/is/isElement.js +14 -1
- package/src/is/isElementInScrollRange.js +4 -2
- package/src/is/isElementInViewport.js +6 -2
- package/src/is/isElementsArray.js +3 -1
- package/src/is/isFunction.js +2 -3
- package/src/is/isHTMLCollection.js +1 -1
- package/src/is/isHTMLElement.js +2 -1
- package/src/is/isHTMLImageElement.js +1 -1
- package/src/is/isMedia.js +5 -3
- package/src/is/isNode.js +2 -1
- package/src/is/isNodeList.js +2 -1
- package/src/is/isNumber.js +8 -0
- package/src/is/isObject.js +8 -0
- package/src/is/isRTL.js +1 -1
- package/src/is/isSVGElement.js +4 -1
- package/src/is/isScaledElement.js +2 -0
- package/src/is/isShadowRoot.js +2 -5
- package/src/is/isString.js +2 -2
- package/src/is/isTableElement.js +5 -1
- package/src/is/isWindow.js +5 -5
- package/src/misc/ObjectEntries.js +7 -0
- package/src/misc/OriginalEvent.js +4 -2
- package/src/misc/createElement.js +3 -1
- package/src/misc/createElementNS.js +7 -3
- package/src/misc/data.js +16 -16
- package/src/misc/dispatchEvent.js +1 -1
- package/src/misc/emulateAnimationEnd.js +5 -2
- package/src/misc/emulateAnimationEndLegacy.js +9 -6
- package/src/misc/emulateTransitionEnd.js +5 -2
- package/src/misc/emulateTransitionEndLegacy.js +9 -6
- package/src/misc/focus.js +1 -2
- package/src/misc/normalizeOptions.js +2 -2
- package/src/misc/normalizeValue.js +8 -6
- package/src/misc/passiveHandlerLegacy.js +2 -1
- package/src/misc/reflow.js +1 -2
- package/src/misc/setElementStyle.js +12 -3
- package/src/misc/timer.js +16 -19
- package/src/misc/version.js +0 -1
- package/src/selectors/closest.js +3 -3
- package/src/selectors/getCustomElements.js +4 -6
- package/src/selectors/getElementById.js +6 -3
- package/src/selectors/getElementsByClassName.js +5 -5
- package/src/selectors/getElementsByTagName.js +5 -5
- package/src/selectors/matches.js +1 -1
- package/src/selectors/matchesLegacy.js +8 -8
- package/src/selectors/querySelector.js +10 -6
- package/src/selectors/querySelectorAll.js +5 -5
- package/src/strings/animationDelayLegacy.js +2 -1
- package/src/strings/animationDurationLegacy.js +2 -1
- package/src/strings/animationEndEventLegacy.js +2 -1
- package/src/strings/animationNameLegacy.js +2 -1
- package/src/strings/mouseHoverEvents.js +2 -1
- package/src/strings/transitionDelayLegacy.js +2 -1
- package/src/strings/transitionDurationLegacy.js +2 -1
- package/src/strings/transitionEndEventLegacy.js +2 -1
- package/src/strings/transitionPropertyLegacy.js +2 -2
- package/src/strings/userAgentData.js +0 -1
- package/types/index.d.ts +10 -5
- package/types/module/shorty.ts +3 -4
- package/types/shorty.d.ts +248 -249
- package/src/misc/tryWrapper.js +0 -11
- package/src/selectors/documentAll.js +0 -8
- package/src/selectors/elementNodes.js +0 -5
- package/src/selectors/parentNodes.js +0 -5
package/dist/shorty.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* Shorty v1.0.
|
|
2
|
+
* Shorty v1.0.3 (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']
|
|
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'
|
|
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'
|
|
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'
|
|
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'
|
|
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'
|
|
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'
|
|
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'
|
|
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'
|
|
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 =
|
|
844
|
-
:
|
|
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')
|
|
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
|
|
866
|
+
var support3DTransform = 'webkitPerspective' in documentHead.style
|
|
867
|
+
|| /* istanbul ignore next */'perspective' in documentHead.style;
|
|
858
868
|
|
|
859
869
|
/**
|
|
860
|
-
* Add eventListener to an `
|
|
870
|
+
* Add eventListener to an `HTMLElement` | `Document` target.
|
|
861
871
|
*
|
|
862
|
-
* @
|
|
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 `
|
|
880
|
+
* Remove eventListener from an `HTMLElement` | `Document` | `Window` target.
|
|
875
881
|
*
|
|
876
|
-
* @
|
|
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 `
|
|
890
|
+
* Add an `eventListener` to an `HTMLElement` | `Document` | `Window`
|
|
889
891
|
* target and remove it once callback is called.
|
|
890
892
|
*
|
|
891
|
-
* @
|
|
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);
|
|
@@ -924,9 +923,10 @@
|
|
|
924
923
|
return result;
|
|
925
924
|
},
|
|
926
925
|
});
|
|
926
|
+
/* istanbul ignore next */
|
|
927
927
|
one(document, DOMContentLoadedEvent, function () {}, opts);
|
|
928
928
|
} catch (e) {
|
|
929
|
-
throw Error('Passive events are not supported');
|
|
929
|
+
// throw Error('Passive events are not supported');
|
|
930
930
|
}
|
|
931
931
|
|
|
932
932
|
return result;
|
|
@@ -936,29 +936,33 @@
|
|
|
936
936
|
* A global `boolean` for CSS3 transform support.
|
|
937
937
|
* @type {boolean}
|
|
938
938
|
*/
|
|
939
|
-
var supportTransform = 'webkitTransform' in documentHead.style
|
|
939
|
+
var supportTransform = 'webkitTransform' in documentHead.style
|
|
940
|
+
|| /* istanbul ignore next */'transform' in documentHead.style;
|
|
940
941
|
|
|
941
942
|
/**
|
|
942
943
|
* A global `boolean` for touch events support.
|
|
943
944
|
* @type {boolean}
|
|
944
945
|
*/
|
|
945
|
-
var supportTouch = 'ontouchstart' in window
|
|
946
|
+
var supportTouch = 'ontouchstart' in window
|
|
947
|
+
|| /* istanbul ignore next */'msMaxTouchPoints' in navigator;
|
|
946
948
|
|
|
947
949
|
/**
|
|
948
950
|
* A global `boolean` for CSS3 animation support.
|
|
949
951
|
* @type {boolean}
|
|
950
952
|
*/
|
|
951
|
-
var supportAnimation = 'webkitAnimation' in documentHead.style
|
|
953
|
+
var supportAnimation = 'webkitAnimation' in documentHead.style
|
|
954
|
+
|| /* istanbul ignore next */'animation' in documentHead.style;
|
|
952
955
|
|
|
953
956
|
/**
|
|
954
957
|
* A global `boolean` for CSS3 transition support.
|
|
955
958
|
* @type {boolean}
|
|
956
959
|
*/
|
|
957
|
-
var supportTransition = 'webkitTransition' in documentHead.style
|
|
960
|
+
var supportTransition = 'webkitTransition' in documentHead.style
|
|
961
|
+
|| /* istanbul ignore next */'transition' in documentHead.style;
|
|
958
962
|
|
|
959
963
|
/**
|
|
960
964
|
* Shortcut for `HTMLElement.getAttribute()` method.
|
|
961
|
-
* @param {HTMLElement
|
|
965
|
+
* @param {HTMLElement} element target element
|
|
962
966
|
* @param {string} attribute attribute name
|
|
963
967
|
* @returns {string?} attribute value
|
|
964
968
|
*/
|
|
@@ -967,7 +971,7 @@
|
|
|
967
971
|
/**
|
|
968
972
|
* Shortcut for `HTMLElement.getAttributeNS()` method.
|
|
969
973
|
* @param {string} ns attribute namespace
|
|
970
|
-
* @param {HTMLElement
|
|
974
|
+
* @param {HTMLElement} element target element
|
|
971
975
|
* @param {string} attribute attribute name
|
|
972
976
|
* @returns {string?} attribute value
|
|
973
977
|
*/
|
|
@@ -975,7 +979,7 @@
|
|
|
975
979
|
|
|
976
980
|
/**
|
|
977
981
|
* Shortcut for `HTMLElement.hasAttribute()` method.
|
|
978
|
-
* @param {HTMLElement
|
|
982
|
+
* @param {HTMLElement} element target element
|
|
979
983
|
* @param {string} attribute attribute name
|
|
980
984
|
* @returns {boolean} the query result
|
|
981
985
|
*/
|
|
@@ -984,7 +988,7 @@
|
|
|
984
988
|
/**
|
|
985
989
|
* Shortcut for `HTMLElement.hasAttributeNS()` method.
|
|
986
990
|
* @param {string} ns attribute namespace
|
|
987
|
-
* @param {HTMLElement
|
|
991
|
+
* @param {HTMLElement} element target element
|
|
988
992
|
* @param {string} att attribute name
|
|
989
993
|
* @returns {boolean} the query result
|
|
990
994
|
*/
|
|
@@ -992,7 +996,7 @@
|
|
|
992
996
|
|
|
993
997
|
/**
|
|
994
998
|
* Shortcut for `HTMLElement.setAttribute()` method.
|
|
995
|
-
* @param {HTMLElement
|
|
999
|
+
* @param {HTMLElement} element target element
|
|
996
1000
|
* @param {string} attribute attribute name
|
|
997
1001
|
* @param {string} value attribute value
|
|
998
1002
|
* @returns {void}
|
|
@@ -1002,7 +1006,7 @@
|
|
|
1002
1006
|
/**
|
|
1003
1007
|
* Shortcut for `SVGElement.setAttributeNS()` method.
|
|
1004
1008
|
* @param {string} ns attribute namespace
|
|
1005
|
-
* @param {HTMLElement
|
|
1009
|
+
* @param {HTMLElement} element target element
|
|
1006
1010
|
* @param {string} att attribute name
|
|
1007
1011
|
* @param {string} value attribute value
|
|
1008
1012
|
* @returns {void}
|
|
@@ -1011,7 +1015,7 @@
|
|
|
1011
1015
|
|
|
1012
1016
|
/**
|
|
1013
1017
|
* Shortcut for `HTMLElement.removeAttribute()` method.
|
|
1014
|
-
* @param {HTMLElement
|
|
1018
|
+
* @param {HTMLElement} element target element
|
|
1015
1019
|
* @param {string} attribute attribute name
|
|
1016
1020
|
* @returns {void}
|
|
1017
1021
|
*/
|
|
@@ -1020,7 +1024,7 @@
|
|
|
1020
1024
|
/**
|
|
1021
1025
|
* Shortcut for `HTMLElement.removeAttributeNS()` method.
|
|
1022
1026
|
* @param {string} ns attribute namespace
|
|
1023
|
-
* @param {HTMLElement
|
|
1027
|
+
* @param {HTMLElement} element target element
|
|
1024
1028
|
* @param {string} att attribute name
|
|
1025
1029
|
* @returns {void}
|
|
1026
1030
|
*/
|
|
@@ -1029,7 +1033,7 @@
|
|
|
1029
1033
|
/**
|
|
1030
1034
|
* Add class to `HTMLElement.classList`.
|
|
1031
1035
|
*
|
|
1032
|
-
* @param {HTMLElement
|
|
1036
|
+
* @param {HTMLElement} element target
|
|
1033
1037
|
* @param {string} classNAME to add
|
|
1034
1038
|
* @returns {void}
|
|
1035
1039
|
*/
|
|
@@ -1040,7 +1044,7 @@
|
|
|
1040
1044
|
/**
|
|
1041
1045
|
* Remove class from `HTMLElement.classList`.
|
|
1042
1046
|
*
|
|
1043
|
-
* @param {HTMLElement
|
|
1047
|
+
* @param {HTMLElement} element target
|
|
1044
1048
|
* @param {string} classNAME to remove
|
|
1045
1049
|
* @returns {void}
|
|
1046
1050
|
*/
|
|
@@ -1051,7 +1055,7 @@
|
|
|
1051
1055
|
/**
|
|
1052
1056
|
* Check class in `HTMLElement.classList`.
|
|
1053
1057
|
*
|
|
1054
|
-
* @param {HTMLElement
|
|
1058
|
+
* @param {HTMLElement} element target
|
|
1055
1059
|
* @param {string} classNAME to check
|
|
1056
1060
|
* @returns {boolean}
|
|
1057
1061
|
*/
|
|
@@ -1068,32 +1072,15 @@
|
|
|
1068
1072
|
var ArrayFrom = function (arr) { return Array.from(arr); };
|
|
1069
1073
|
|
|
1070
1074
|
/**
|
|
1071
|
-
*
|
|
1072
|
-
* @see https://
|
|
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.
|
|
1075
|
+
* Checks if an element is an `HTMLElement`.
|
|
1076
|
+
* @see https://dom.spec.whatwg.org/#node
|
|
1085
1077
|
*
|
|
1086
|
-
* @param {
|
|
1087
|
-
* @
|
|
1088
|
-
* @return {(HTMLElement | Element)?} the `HTMLElement` or `querySelector` result
|
|
1078
|
+
* @param {any} element the target object
|
|
1079
|
+
* @returns {boolean} the query result
|
|
1089
1080
|
*/
|
|
1090
|
-
function
|
|
1091
|
-
var method = 'querySelector';
|
|
1092
|
-
var lookUp = parent && parent[method] ? parent : getDocument();
|
|
1093
|
-
return selector[method] ? selector : lookUp[method](selector);
|
|
1094
|
-
}
|
|
1081
|
+
var isHTMLElement = function (element) { return (element && element.nodeType === 1) || false; };
|
|
1095
1082
|
|
|
1096
|
-
/** @type {Map<string, Map<HTMLElement
|
|
1083
|
+
/** @type {Map<string, Map<HTMLElement, Record<string, any>>>} */
|
|
1097
1084
|
var componentData = new Map();
|
|
1098
1085
|
/**
|
|
1099
1086
|
* An interface for web components background data.
|
|
@@ -1102,27 +1089,27 @@
|
|
|
1102
1089
|
var Data = {
|
|
1103
1090
|
/**
|
|
1104
1091
|
* Sets web components data.
|
|
1105
|
-
* @param {HTMLElement
|
|
1092
|
+
* @param {HTMLElement} element target element
|
|
1106
1093
|
* @param {string} component the component's name or a unique key
|
|
1107
1094
|
* @param {Record<string, any>} instance the component instance
|
|
1108
1095
|
*/
|
|
1109
|
-
set: function (
|
|
1110
|
-
|
|
1111
|
-
if (!element) { return; }
|
|
1096
|
+
set: function (element, component, instance) {
|
|
1097
|
+
if (!isHTMLElement(element)) { return; }
|
|
1112
1098
|
|
|
1099
|
+
/* istanbul ignore else */
|
|
1113
1100
|
if (!componentData.has(component)) {
|
|
1114
1101
|
componentData.set(component, new Map());
|
|
1115
1102
|
}
|
|
1116
1103
|
|
|
1117
1104
|
var instanceMap = componentData.get(component);
|
|
1118
|
-
//
|
|
1105
|
+
// not undefined, but defined right above
|
|
1119
1106
|
instanceMap.set(element, instance);
|
|
1120
1107
|
},
|
|
1121
1108
|
|
|
1122
1109
|
/**
|
|
1123
1110
|
* Returns all instances for specified component.
|
|
1124
1111
|
* @param {string} component the component's name or a unique key
|
|
1125
|
-
* @returns {Map<HTMLElement
|
|
1112
|
+
* @returns {Map<HTMLElement, Record<string, any>>?} all the component instances
|
|
1126
1113
|
*/
|
|
1127
1114
|
getAllFor: function (component) {
|
|
1128
1115
|
var instanceMap = componentData.get(component);
|
|
@@ -1132,12 +1119,12 @@
|
|
|
1132
1119
|
|
|
1133
1120
|
/**
|
|
1134
1121
|
* Returns the instance associated with the target.
|
|
1135
|
-
* @param {HTMLElement
|
|
1122
|
+
* @param {HTMLElement} element target element
|
|
1136
1123
|
* @param {string} component the component's name or a unique key
|
|
1137
1124
|
* @returns {Record<string, any>?} the instance
|
|
1138
1125
|
*/
|
|
1139
|
-
get: function (
|
|
1140
|
-
|
|
1126
|
+
get: function (element, component) {
|
|
1127
|
+
if (!isHTMLElement(element) || !component) { return null; }
|
|
1141
1128
|
var allForC = Data.getAllFor(component);
|
|
1142
1129
|
var instance = element && allForC && allForC.get(element);
|
|
1143
1130
|
|
|
@@ -1146,16 +1133,16 @@
|
|
|
1146
1133
|
|
|
1147
1134
|
/**
|
|
1148
1135
|
* Removes web components data.
|
|
1149
|
-
* @param {HTMLElement
|
|
1136
|
+
* @param {HTMLElement} element target element
|
|
1150
1137
|
* @param {string} component the component's name or a unique key
|
|
1151
1138
|
*/
|
|
1152
|
-
remove: function (
|
|
1153
|
-
var element = querySelector(target);
|
|
1139
|
+
remove: function (element, component) {
|
|
1154
1140
|
var instanceMap = componentData.get(component);
|
|
1155
|
-
if (!instanceMap || !element) { return; }
|
|
1141
|
+
if (!instanceMap || !isHTMLElement(element)) { return; }
|
|
1156
1142
|
|
|
1157
1143
|
instanceMap.delete(element);
|
|
1158
1144
|
|
|
1145
|
+
/* istanbul ignore else */
|
|
1159
1146
|
if (instanceMap.size === 0) {
|
|
1160
1147
|
componentData.delete(component);
|
|
1161
1148
|
}
|
|
@@ -1164,10 +1151,54 @@
|
|
|
1164
1151
|
|
|
1165
1152
|
/**
|
|
1166
1153
|
* An alias for `Data.get()`.
|
|
1167
|
-
* @type {
|
|
1154
|
+
* @type {SHORTY.getInstance<any>}
|
|
1168
1155
|
*/
|
|
1169
1156
|
var getInstance = function (target, component) { return Data.get(target, component); };
|
|
1170
1157
|
|
|
1158
|
+
/**
|
|
1159
|
+
* Checks if an object is a `Node`.
|
|
1160
|
+
*
|
|
1161
|
+
* @param {any} node the target object
|
|
1162
|
+
* @returns {boolean} the query result
|
|
1163
|
+
*/
|
|
1164
|
+
var isNode = function (element) { return (element && [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]
|
|
1165
|
+
.some(function (x) { return +element.nodeType === x; })) || false; };
|
|
1166
|
+
|
|
1167
|
+
/**
|
|
1168
|
+
* Check if a target object is `Window`.
|
|
1169
|
+
* => equivalent to `object instanceof Window`
|
|
1170
|
+
*
|
|
1171
|
+
* @param {any} object the target object
|
|
1172
|
+
* @returns {boolean} the query result
|
|
1173
|
+
*/
|
|
1174
|
+
var isWindow = function (object) { return (object && object.constructor.name === 'Window') || false; };
|
|
1175
|
+
|
|
1176
|
+
/**
|
|
1177
|
+
* Checks if an object is a `Document`.
|
|
1178
|
+
* @see https://dom.spec.whatwg.org/#node
|
|
1179
|
+
*
|
|
1180
|
+
* @param {any} object the target object
|
|
1181
|
+
* @returns {boolean} the query result
|
|
1182
|
+
*/
|
|
1183
|
+
var isDocument = function (object) { return (object && object.nodeType === 9) || false; };
|
|
1184
|
+
|
|
1185
|
+
/**
|
|
1186
|
+
* Returns the `document` or the `#document` element.
|
|
1187
|
+
* @see https://github.com/floating-ui/floating-ui
|
|
1188
|
+
* @param {(Node | Window)=} node
|
|
1189
|
+
* @returns {Document}
|
|
1190
|
+
*/
|
|
1191
|
+
function getDocument(node) {
|
|
1192
|
+
// node instanceof Document
|
|
1193
|
+
if (isDocument(node)) { return node; }
|
|
1194
|
+
// node instanceof Node
|
|
1195
|
+
if (isNode(node)) { return node.ownerDocument; }
|
|
1196
|
+
// node instanceof Window
|
|
1197
|
+
if (isWindow(node)) { return node.document; }
|
|
1198
|
+
// node is undefined | NULL
|
|
1199
|
+
return window.document;
|
|
1200
|
+
}
|
|
1201
|
+
|
|
1171
1202
|
/**
|
|
1172
1203
|
* Shortcut for `Object.assign()` static method.
|
|
1173
1204
|
* @param {Record<string, any>} obj a target object
|
|
@@ -1183,9 +1214,11 @@
|
|
|
1183
1214
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/Document/createElement
|
|
1184
1215
|
*
|
|
1185
1216
|
* @param {Record<string, string> | string} param `tagName` or object
|
|
1186
|
-
* @return {HTMLElement
|
|
1217
|
+
* @return {HTMLElement} a new `HTMLElement` or `Element`
|
|
1187
1218
|
*/
|
|
1188
1219
|
function createElement(param) {
|
|
1220
|
+
if (!param) { return null; }
|
|
1221
|
+
|
|
1189
1222
|
if (typeof param === 'string') {
|
|
1190
1223
|
return getDocument().createElement(param);
|
|
1191
1224
|
}
|
|
@@ -1198,6 +1231,13 @@
|
|
|
1198
1231
|
return newElement;
|
|
1199
1232
|
}
|
|
1200
1233
|
|
|
1234
|
+
/**
|
|
1235
|
+
* Shortcut for `Object.entries()` static method.
|
|
1236
|
+
* @param {Record<string, any>} obj a target object
|
|
1237
|
+
* @returns {[string, any][]}
|
|
1238
|
+
*/
|
|
1239
|
+
var ObjectEntries = function (obj) { return Object.entries(obj); };
|
|
1240
|
+
|
|
1201
1241
|
/**
|
|
1202
1242
|
* This is a shortie for `document.createElementNS` method
|
|
1203
1243
|
* which allows you to create a new `HTMLElement` for a given `tagName`
|
|
@@ -1207,9 +1247,10 @@
|
|
|
1207
1247
|
*
|
|
1208
1248
|
* @param {string} namespace `namespaceURI` to associate with the new `HTMLElement`
|
|
1209
1249
|
* @param {Record<string, string> | string} param `tagName` or object
|
|
1210
|
-
* @return {HTMLElement
|
|
1250
|
+
* @return {HTMLElement} a new `HTMLElement` or `Element`
|
|
1211
1251
|
*/
|
|
1212
1252
|
function createElementNS(namespace, param) {
|
|
1253
|
+
if (!namespace && !param) { return null; }
|
|
1213
1254
|
if (typeof param === 'string') {
|
|
1214
1255
|
return getDocument().createElementNS(namespace, param);
|
|
1215
1256
|
}
|
|
@@ -1218,14 +1259,19 @@
|
|
|
1218
1259
|
var attr = Object.assign({}, param);
|
|
1219
1260
|
var newElement = createElementNS(namespace, tagName);
|
|
1220
1261
|
delete attr.tagName;
|
|
1221
|
-
|
|
1262
|
+
ObjectEntries(attr).forEach(function (ref) {
|
|
1263
|
+
var key = ref[0];
|
|
1264
|
+
var value = ref[1];
|
|
1265
|
+
|
|
1266
|
+
setAttribute(newElement, key, value);
|
|
1267
|
+
});
|
|
1222
1268
|
return newElement;
|
|
1223
1269
|
}
|
|
1224
1270
|
|
|
1225
1271
|
/**
|
|
1226
1272
|
* Shortcut for the `Element.dispatchEvent(Event)` method.
|
|
1227
1273
|
*
|
|
1228
|
-
* @param {HTMLElement
|
|
1274
|
+
* @param {HTMLElement} element is the target
|
|
1229
1275
|
* @param {Event} event is the `Event` object
|
|
1230
1276
|
*/
|
|
1231
1277
|
var dispatchEvent = function (element, event) { return element.dispatchEvent(event); };
|
|
@@ -1247,33 +1293,35 @@
|
|
|
1247
1293
|
* * If `element` parameter is not an `HTMLElement`, `getComputedStyle`
|
|
1248
1294
|
* throws a `ReferenceError`.
|
|
1249
1295
|
*
|
|
1250
|
-
* @param {HTMLElement
|
|
1296
|
+
* @param {HTMLElement} element target
|
|
1251
1297
|
* @param {string} property the css property
|
|
1252
1298
|
* @return {string} the css property value
|
|
1253
1299
|
*/
|
|
1254
1300
|
function getElementStyle(element, property) {
|
|
1255
1301
|
var computedStyle = getComputedStyle(element);
|
|
1256
1302
|
|
|
1257
|
-
//
|
|
1303
|
+
// must use camelcase strings,
|
|
1258
1304
|
// or non-camelcase strings with `getPropertyValue`
|
|
1259
|
-
return property
|
|
1305
|
+
return property.includes('--')
|
|
1306
|
+
? computedStyle.getPropertyValue(property)
|
|
1307
|
+
: computedStyle[property];
|
|
1260
1308
|
}
|
|
1261
1309
|
|
|
1262
1310
|
/**
|
|
1263
1311
|
* Utility to get the computed `animationDelay`
|
|
1264
1312
|
* from Element in miliseconds.
|
|
1265
1313
|
*
|
|
1266
|
-
* @param {HTMLElement
|
|
1314
|
+
* @param {HTMLElement} element target
|
|
1267
1315
|
* @return {number} the value in miliseconds
|
|
1268
1316
|
*/
|
|
1269
1317
|
function getElementAnimationDelay$1(element) {
|
|
1270
1318
|
var propertyValue = getElementStyle(element, animationName$1);
|
|
1271
1319
|
var durationValue = getElementStyle(element, animationDelay$1);
|
|
1272
|
-
|
|
1273
|
-
var durationScale = durationValue.includes('ms') ? 1 : 1000;
|
|
1320
|
+
var durationScale = durationValue.includes('ms') ? /* istanbul ignore next */1 : 1000;
|
|
1274
1321
|
var duration = propertyValue && propertyValue !== 'none'
|
|
1275
1322
|
? parseFloat(durationValue) * durationScale : 0;
|
|
1276
1323
|
|
|
1324
|
+
/* istanbul ignore next */
|
|
1277
1325
|
return !Number.isNaN(duration) ? duration : 0;
|
|
1278
1326
|
}
|
|
1279
1327
|
|
|
@@ -1281,24 +1329,24 @@
|
|
|
1281
1329
|
* Utility to get the computed `animationDuration`
|
|
1282
1330
|
* from `HTMLElement` in miliseconds.
|
|
1283
1331
|
*
|
|
1284
|
-
* @param {HTMLElement
|
|
1332
|
+
* @param {HTMLElement} element target
|
|
1285
1333
|
* @return {number} the value in miliseconds
|
|
1286
1334
|
*/
|
|
1287
1335
|
function getElementAnimationDuration$1(element) {
|
|
1288
1336
|
var propertyValue = getElementStyle(element, animationName$1);
|
|
1289
1337
|
var durationValue = getElementStyle(element, animationDuration$1);
|
|
1290
|
-
var durationScale = durationValue.includes('ms') ? 1 : 1000;
|
|
1338
|
+
var durationScale = durationValue.includes('ms') ? /* istanbul ignore next */1 : 1000;
|
|
1291
1339
|
var duration = propertyValue && propertyValue !== 'none'
|
|
1292
1340
|
? parseFloat(durationValue) * durationScale : 0;
|
|
1293
1341
|
|
|
1294
|
-
return !Number.isNaN(duration) ? duration : 0;
|
|
1342
|
+
return !Number.isNaN(duration) ? duration : /* istanbul ignore next */0;
|
|
1295
1343
|
}
|
|
1296
1344
|
|
|
1297
1345
|
/**
|
|
1298
1346
|
* Utility to make sure callbacks are consistently
|
|
1299
1347
|
* called when animation ends.
|
|
1300
1348
|
*
|
|
1301
|
-
* @param {HTMLElement
|
|
1349
|
+
* @param {HTMLElement} element target
|
|
1302
1350
|
* @param {EventListener} handler `animationend` callback
|
|
1303
1351
|
*/
|
|
1304
1352
|
function emulateAnimationEnd$1(element, handler) {
|
|
@@ -1313,6 +1361,7 @@
|
|
|
1313
1361
|
* @type {EventListener}
|
|
1314
1362
|
*/
|
|
1315
1363
|
var animationEndWrapper = function (e) {
|
|
1364
|
+
/* istanbul ignore else */
|
|
1316
1365
|
if (e.target === element) {
|
|
1317
1366
|
handler.apply(element, [e]);
|
|
1318
1367
|
element.removeEventListener(animationEndEvent$1, animationEndWrapper);
|
|
@@ -1321,7 +1370,8 @@
|
|
|
1321
1370
|
};
|
|
1322
1371
|
element.addEventListener(animationEndEvent$1, animationEndWrapper);
|
|
1323
1372
|
setTimeout(function () {
|
|
1324
|
-
|
|
1373
|
+
/* istanbul ignore next */
|
|
1374
|
+
if (!called) { dispatchEvent(element, endEvent); }
|
|
1325
1375
|
}, duration + delay + 17);
|
|
1326
1376
|
} else {
|
|
1327
1377
|
handler.apply(element, [endEvent]);
|
|
@@ -1332,41 +1382,41 @@
|
|
|
1332
1382
|
* Utility to get the computed `animationDelay`
|
|
1333
1383
|
* from Element in miliseconds.
|
|
1334
1384
|
*
|
|
1335
|
-
* @param {HTMLElement
|
|
1385
|
+
* @param {HTMLElement} element target
|
|
1336
1386
|
* @return {number} the value in miliseconds
|
|
1337
1387
|
*/
|
|
1338
1388
|
function getElementAnimationDelay(element) {
|
|
1339
1389
|
var propertyValue = getElementStyle(element, animationName);
|
|
1340
1390
|
var durationValue = getElementStyle(element, animationDelay);
|
|
1341
|
-
var durationScale = durationValue.includes('ms') ? 1 : 1000;
|
|
1391
|
+
var durationScale = durationValue.includes('ms') ? /* istanbul ignore next */1 : 1000;
|
|
1342
1392
|
var duration = supportAnimation && propertyValue && propertyValue !== 'none'
|
|
1343
1393
|
? parseFloat(durationValue) * durationScale : 0;
|
|
1344
1394
|
|
|
1345
|
-
return !Number.isNaN(duration) ? duration : 0;
|
|
1395
|
+
return !Number.isNaN(duration) ? duration : /* istanbul ignore next */0;
|
|
1346
1396
|
}
|
|
1347
1397
|
|
|
1348
1398
|
/**
|
|
1349
1399
|
* Utility to get the computed `animationDuration`
|
|
1350
1400
|
* from `HTMLElement` in miliseconds.
|
|
1351
1401
|
*
|
|
1352
|
-
* @param {HTMLElement
|
|
1402
|
+
* @param {HTMLElement} element target
|
|
1353
1403
|
* @return {number} the value in miliseconds
|
|
1354
1404
|
*/
|
|
1355
1405
|
function getElementAnimationDuration(element) {
|
|
1356
1406
|
var propertyValue = getElementStyle(element, animationName);
|
|
1357
1407
|
var durationValue = getElementStyle(element, animationDuration);
|
|
1358
|
-
var durationScale = durationValue.includes('ms') ? 1 : 1000;
|
|
1408
|
+
var durationScale = durationValue.includes('ms') ? /* istanbul ignore next */1 : 1000;
|
|
1359
1409
|
var duration = supportAnimation && propertyValue && propertyValue !== 'none'
|
|
1360
1410
|
? parseFloat(durationValue) * durationScale : 0;
|
|
1361
1411
|
|
|
1362
|
-
return !Number.isNaN(duration) ? duration : 0;
|
|
1412
|
+
return !Number.isNaN(duration) ? duration : /* istanbul ignore next */0;
|
|
1363
1413
|
}
|
|
1364
1414
|
|
|
1365
1415
|
/**
|
|
1366
1416
|
* Utility to make sure callbacks are consistently
|
|
1367
1417
|
* called when animation ends.
|
|
1368
1418
|
*
|
|
1369
|
-
* @param {HTMLElement
|
|
1419
|
+
* @param {HTMLElement} element target
|
|
1370
1420
|
* @param {EventListener} handler `animationend` callback
|
|
1371
1421
|
*/
|
|
1372
1422
|
function emulateAnimationEnd(element, handler) {
|
|
@@ -1381,6 +1431,7 @@
|
|
|
1381
1431
|
* @param {Event} e Event object
|
|
1382
1432
|
*/
|
|
1383
1433
|
var animationEndWrapper = function (e) {
|
|
1434
|
+
/* istanbul ignore else */
|
|
1384
1435
|
if (e.target === element) {
|
|
1385
1436
|
handler.apply(element, [e]);
|
|
1386
1437
|
element.removeEventListener(animationEndEvent, animationEndWrapper);
|
|
@@ -1389,7 +1440,8 @@
|
|
|
1389
1440
|
};
|
|
1390
1441
|
element.addEventListener(animationEndEvent, animationEndWrapper);
|
|
1391
1442
|
setTimeout(function () {
|
|
1392
|
-
|
|
1443
|
+
/* istanbul ignore next */
|
|
1444
|
+
if (!called) { dispatchEvent(element, endEvent); }
|
|
1393
1445
|
}, duration + delay + 17);
|
|
1394
1446
|
} else {
|
|
1395
1447
|
handler.apply(element, [endEvent]);
|
|
@@ -1400,42 +1452,41 @@
|
|
|
1400
1452
|
* Utility to get the computed `transitionDelay`
|
|
1401
1453
|
* from Element in miliseconds.
|
|
1402
1454
|
*
|
|
1403
|
-
* @param {HTMLElement
|
|
1455
|
+
* @param {HTMLElement} element target
|
|
1404
1456
|
* @return {number} the value in miliseconds
|
|
1405
1457
|
*/
|
|
1406
1458
|
function getElementTransitionDelay$1(element) {
|
|
1407
1459
|
var propertyValue = getElementStyle(element, transitionProperty$1);
|
|
1408
1460
|
var delayValue = getElementStyle(element, transitionDelay$1);
|
|
1409
|
-
|
|
1410
|
-
var delayScale = delayValue.includes('ms') ? 1 : 1000;
|
|
1461
|
+
var delayScale = delayValue.includes('ms') ? /* istanbul ignore next */1 : 1000;
|
|
1411
1462
|
var duration = propertyValue && propertyValue !== 'none'
|
|
1412
1463
|
? parseFloat(delayValue) * delayScale : 0;
|
|
1413
1464
|
|
|
1414
|
-
return !Number.isNaN(duration) ? duration : 0;
|
|
1465
|
+
return !Number.isNaN(duration) ? duration : /* istanbul ignore next */0;
|
|
1415
1466
|
}
|
|
1416
1467
|
|
|
1417
1468
|
/**
|
|
1418
1469
|
* Utility to get the computed `transitionDuration`
|
|
1419
1470
|
* from Element in miliseconds.
|
|
1420
1471
|
*
|
|
1421
|
-
* @param {HTMLElement
|
|
1472
|
+
* @param {HTMLElement} element target
|
|
1422
1473
|
* @return {number} the value in miliseconds
|
|
1423
1474
|
*/
|
|
1424
1475
|
function getElementTransitionDuration$1(element) {
|
|
1425
1476
|
var propertyValue = getElementStyle(element, transitionProperty$1);
|
|
1426
1477
|
var durationValue = getElementStyle(element, transitionDuration$1);
|
|
1427
|
-
var durationScale = durationValue.includes('ms') ? 1 : 1000;
|
|
1478
|
+
var durationScale = durationValue.includes('ms') ? /* istanbul ignore next */1 : 1000;
|
|
1428
1479
|
var duration = propertyValue && propertyValue !== 'none'
|
|
1429
1480
|
? parseFloat(durationValue) * durationScale : 0;
|
|
1430
1481
|
|
|
1431
|
-
return !Number.isNaN(duration) ? duration : 0;
|
|
1482
|
+
return !Number.isNaN(duration) ? duration : /* istanbul ignore next */0;
|
|
1432
1483
|
}
|
|
1433
1484
|
|
|
1434
1485
|
/**
|
|
1435
1486
|
* Utility to make sure callbacks are consistently
|
|
1436
1487
|
* called when transition ends.
|
|
1437
1488
|
*
|
|
1438
|
-
* @param {HTMLElement
|
|
1489
|
+
* @param {HTMLElement} element target
|
|
1439
1490
|
* @param {EventListener} handler `transitionend` callback
|
|
1440
1491
|
*/
|
|
1441
1492
|
function emulateTransitionEnd$1(element, handler) {
|
|
@@ -1450,6 +1501,7 @@
|
|
|
1450
1501
|
* @type {EventListener} e Event object
|
|
1451
1502
|
*/
|
|
1452
1503
|
var transitionEndWrapper = function (e) {
|
|
1504
|
+
/* istanbul ignore else */
|
|
1453
1505
|
if (e.target === element) {
|
|
1454
1506
|
handler.apply(element, [e]);
|
|
1455
1507
|
element.removeEventListener(transitionEndEvent$1, transitionEndWrapper);
|
|
@@ -1458,7 +1510,8 @@
|
|
|
1458
1510
|
};
|
|
1459
1511
|
element.addEventListener(transitionEndEvent$1, transitionEndWrapper);
|
|
1460
1512
|
setTimeout(function () {
|
|
1461
|
-
|
|
1513
|
+
/* istanbul ignore next */
|
|
1514
|
+
if (!called) { dispatchEvent(element, endEvent); }
|
|
1462
1515
|
}, duration + delay + 17);
|
|
1463
1516
|
} else {
|
|
1464
1517
|
handler.apply(element, [endEvent]);
|
|
@@ -1469,41 +1522,41 @@
|
|
|
1469
1522
|
* Utility to get the computed `transitionDelay`
|
|
1470
1523
|
* from Element in miliseconds.
|
|
1471
1524
|
*
|
|
1472
|
-
* @param {HTMLElement
|
|
1525
|
+
* @param {HTMLElement} element target
|
|
1473
1526
|
* @return {number} the value in miliseconds
|
|
1474
1527
|
*/
|
|
1475
1528
|
function getElementTransitionDelay(element) {
|
|
1476
1529
|
var propertyValue = getElementStyle(element, transitionProperty);
|
|
1477
1530
|
var delayValue = getElementStyle(element, transitionDelay);
|
|
1478
|
-
var delayScale = delayValue.includes('ms') ? 1 : 1000;
|
|
1531
|
+
var delayScale = delayValue.includes('ms') ? /* istanbul ignore next */1 : 1000;
|
|
1479
1532
|
var duration = supportTransition && propertyValue && propertyValue !== 'none'
|
|
1480
1533
|
? parseFloat(delayValue) * delayScale : 0;
|
|
1481
1534
|
|
|
1482
|
-
return !Number.isNaN(duration) ? duration : 0;
|
|
1535
|
+
return !Number.isNaN(duration) ? duration : /* istanbul ignore next */0;
|
|
1483
1536
|
}
|
|
1484
1537
|
|
|
1485
1538
|
/**
|
|
1486
1539
|
* Utility to get the computed `transitionDuration`
|
|
1487
1540
|
* from Element in miliseconds.
|
|
1488
1541
|
*
|
|
1489
|
-
* @param {HTMLElement
|
|
1542
|
+
* @param {HTMLElement} element target
|
|
1490
1543
|
* @return {number} the value in miliseconds
|
|
1491
1544
|
*/
|
|
1492
1545
|
function getElementTransitionDuration(element) {
|
|
1493
1546
|
var propertyValue = getElementStyle(element, transitionProperty);
|
|
1494
1547
|
var durationValue = getElementStyle(element, transitionDuration);
|
|
1495
|
-
var durationScale = durationValue.includes('ms') ? 1 : 1000;
|
|
1548
|
+
var durationScale = durationValue.includes('ms') ? /* istanbul ignore next */1 : 1000;
|
|
1496
1549
|
var duration = supportTransition && propertyValue && propertyValue !== 'none'
|
|
1497
1550
|
? parseFloat(durationValue) * durationScale : 0;
|
|
1498
1551
|
|
|
1499
|
-
return !Number.isNaN(duration) ? duration : 0;
|
|
1552
|
+
return !Number.isNaN(duration) ? duration : /* istanbul ignore next */0;
|
|
1500
1553
|
}
|
|
1501
1554
|
|
|
1502
1555
|
/**
|
|
1503
1556
|
* Utility to make sure callbacks are consistently
|
|
1504
1557
|
* called when transition ends.
|
|
1505
1558
|
*
|
|
1506
|
-
* @param {HTMLElement
|
|
1559
|
+
* @param {HTMLElement} element target
|
|
1507
1560
|
* @param {EventListener} handler `transitionend` callback
|
|
1508
1561
|
*/
|
|
1509
1562
|
function emulateTransitionEnd(element, handler) {
|
|
@@ -1518,6 +1571,7 @@
|
|
|
1518
1571
|
* @param {Event} e Event object
|
|
1519
1572
|
*/
|
|
1520
1573
|
var transitionEndWrapper = function (e) {
|
|
1574
|
+
/* istanbul ignore else */
|
|
1521
1575
|
if (e.target === element) {
|
|
1522
1576
|
handler.apply(element, [e]);
|
|
1523
1577
|
element.removeEventListener(transitionEndEvent, transitionEndWrapper);
|
|
@@ -1526,7 +1580,8 @@
|
|
|
1526
1580
|
};
|
|
1527
1581
|
element.addEventListener(transitionEndEvent, transitionEndWrapper);
|
|
1528
1582
|
setTimeout(function () {
|
|
1529
|
-
|
|
1583
|
+
/* istanbul ignore next */
|
|
1584
|
+
if (!called) { dispatchEvent(element, endEvent); }
|
|
1530
1585
|
}, duration + delay + 17);
|
|
1531
1586
|
} else {
|
|
1532
1587
|
handler.apply(element, [endEvent]);
|
|
@@ -1550,9 +1605,8 @@
|
|
|
1550
1605
|
/**
|
|
1551
1606
|
* Utility to focus an `HTMLElement` target.
|
|
1552
1607
|
*
|
|
1553
|
-
* @param {HTMLElement
|
|
1608
|
+
* @param {HTMLElement} element is the target
|
|
1554
1609
|
*/
|
|
1555
|
-
// @ts-ignore -- `Element`s resulted from querySelector can focus too
|
|
1556
1610
|
var focus = function (element) { return element.focus(); };
|
|
1557
1611
|
|
|
1558
1612
|
/** A generic function with empty body. */
|
|
@@ -1571,22 +1625,24 @@
|
|
|
1571
1625
|
* @return {niceValue} the normalized value
|
|
1572
1626
|
*/
|
|
1573
1627
|
function normalizeValue(value) {
|
|
1574
|
-
if (
|
|
1628
|
+
if (['true', true].includes(value)) { // boolean
|
|
1629
|
+
// if ('true' === value) { // boolean
|
|
1575
1630
|
return true;
|
|
1576
1631
|
}
|
|
1577
1632
|
|
|
1578
|
-
if (
|
|
1633
|
+
if (['false', false].includes(value)) { // boolean
|
|
1634
|
+
// if ('false' === value) { // boolean
|
|
1579
1635
|
return false;
|
|
1580
1636
|
}
|
|
1581
1637
|
|
|
1582
|
-
if (!Number.isNaN(+value)) { // number
|
|
1583
|
-
return +value;
|
|
1584
|
-
}
|
|
1585
|
-
|
|
1586
1638
|
if (value === '' || value === 'null') { // null
|
|
1587
1639
|
return null;
|
|
1588
1640
|
}
|
|
1589
1641
|
|
|
1642
|
+
if (value !== '' && !Number.isNaN(+value)) { // number
|
|
1643
|
+
return +value;
|
|
1644
|
+
}
|
|
1645
|
+
|
|
1590
1646
|
// string / function / HTMLElement / object
|
|
1591
1647
|
return value;
|
|
1592
1648
|
}
|
|
@@ -1609,14 +1665,13 @@
|
|
|
1609
1665
|
/**
|
|
1610
1666
|
* Utility to normalize component options.
|
|
1611
1667
|
*
|
|
1612
|
-
* @param {HTMLElement
|
|
1668
|
+
* @param {HTMLElement} element target
|
|
1613
1669
|
* @param {Record<string, any>} defaultOps component default options
|
|
1614
1670
|
* @param {Record<string, any>} inputOps component instance options
|
|
1615
1671
|
* @param {string=} ns component namespace
|
|
1616
1672
|
* @return {Record<string, any>} normalized component options object
|
|
1617
1673
|
*/
|
|
1618
1674
|
function normalizeOptions(element, defaultOps, inputOps, ns) {
|
|
1619
|
-
// @ts-ignore -- our targets are always `HTMLElement`
|
|
1620
1675
|
var data = Object.assign({}, element.dataset);
|
|
1621
1676
|
/** @type {Record<string, any>} */
|
|
1622
1677
|
var normalOps = {};
|
|
@@ -1637,6 +1692,7 @@
|
|
|
1637
1692
|
});
|
|
1638
1693
|
|
|
1639
1694
|
ObjectKeys(defaultOps).forEach(function (k) {
|
|
1695
|
+
/* istanbul ignore else */
|
|
1640
1696
|
if (k in inputOps) {
|
|
1641
1697
|
normalOps[k] = inputOps[k];
|
|
1642
1698
|
} else if (k in dataOps) {
|
|
@@ -1658,18 +1714,27 @@
|
|
|
1658
1714
|
*/
|
|
1659
1715
|
var ObjectValues = function (obj) { return Object.values(obj); };
|
|
1660
1716
|
|
|
1717
|
+
/**
|
|
1718
|
+
* Checks if an object is an `Object`.
|
|
1719
|
+
*
|
|
1720
|
+
* @param {any} obj the target object
|
|
1721
|
+
* @returns {boolean} the query result
|
|
1722
|
+
*/
|
|
1723
|
+
var isObject = function (obj) { return (typeof obj === 'object') || false; };
|
|
1724
|
+
|
|
1661
1725
|
/**
|
|
1662
1726
|
* Returns a namespaced `CustomEvent` specific to each component.
|
|
1663
1727
|
* @param {string} EventType Event.type
|
|
1664
1728
|
* @param {Record<string, any>=} config Event.options | Event.properties
|
|
1665
|
-
* @returns {
|
|
1729
|
+
* @returns {SHORTY.OriginalEvent} a new namespaced event
|
|
1666
1730
|
*/
|
|
1667
1731
|
function OriginalEvent(EventType, config) {
|
|
1668
1732
|
var OriginalCustomEvent = new CustomEvent(EventType, {
|
|
1669
1733
|
cancelable: true, bubbles: true,
|
|
1670
1734
|
});
|
|
1671
1735
|
|
|
1672
|
-
|
|
1736
|
+
/* istanbul ignore else */
|
|
1737
|
+
if (isObject(config)) {
|
|
1673
1738
|
ObjectAssign(OriginalCustomEvent, config);
|
|
1674
1739
|
}
|
|
1675
1740
|
return OriginalCustomEvent;
|
|
@@ -1685,26 +1750,37 @@
|
|
|
1685
1750
|
* A global namespace for most scroll event listeners in legacy browsers.
|
|
1686
1751
|
* @type {Partial<AddEventListenerOptions> | boolean}
|
|
1687
1752
|
*/
|
|
1688
|
-
var passiveHandler = supportPassive ? { passive: true }
|
|
1753
|
+
var passiveHandler = supportPassive ? { passive: true }
|
|
1754
|
+
: /* istanbul ignore next */false;
|
|
1689
1755
|
|
|
1690
1756
|
/**
|
|
1691
1757
|
* Utility to force re-paint of an `HTMLElement` target.
|
|
1692
1758
|
*
|
|
1693
|
-
* @param {HTMLElement
|
|
1759
|
+
* @param {HTMLElement} element is the target
|
|
1694
1760
|
* @return {number} the `Element.offsetHeight` value
|
|
1695
1761
|
*/
|
|
1696
|
-
// @ts-ignore
|
|
1697
1762
|
var reflow = function (element) { return element.offsetHeight; };
|
|
1698
1763
|
|
|
1699
1764
|
/**
|
|
1700
1765
|
* Shortcut for multiple uses of `HTMLElement.style.propertyName` method.
|
|
1701
|
-
* @param {HTMLElement
|
|
1766
|
+
* @param {HTMLElement} element target element
|
|
1702
1767
|
* @param {Partial<CSSStyleDeclaration>} styles attribute value
|
|
1703
1768
|
*/
|
|
1704
|
-
|
|
1705
|
-
|
|
1769
|
+
var setElementStyle = function (element, styles) {
|
|
1770
|
+
ObjectEntries(styles).forEach(function (ref) {
|
|
1771
|
+
var key = ref[0];
|
|
1772
|
+
var value = ref[1];
|
|
1773
|
+
|
|
1774
|
+
if (key.includes('--')) {
|
|
1775
|
+
element.style.setProperty(key, value);
|
|
1776
|
+
} else {
|
|
1777
|
+
var propObject = {}; propObject[key] = value;
|
|
1778
|
+
ObjectAssign(element.style, propObject);
|
|
1779
|
+
}
|
|
1780
|
+
});
|
|
1781
|
+
};
|
|
1706
1782
|
|
|
1707
|
-
/** @type {Map<HTMLElement
|
|
1783
|
+
/** @type {Map<HTMLElement, any>} */
|
|
1708
1784
|
var TimeCache = new Map();
|
|
1709
1785
|
/**
|
|
1710
1786
|
* An interface for one or more `TimerHandler`s per `Element`.
|
|
@@ -1713,17 +1789,17 @@
|
|
|
1713
1789
|
var Timer = {
|
|
1714
1790
|
/**
|
|
1715
1791
|
* Sets a new timeout timer for an element, or element -> key association.
|
|
1716
|
-
* @param {HTMLElement
|
|
1792
|
+
* @param {HTMLElement} element target element
|
|
1717
1793
|
* @param {ReturnType<TimerHandler>} callback the callback
|
|
1718
1794
|
* @param {number} delay the execution delay
|
|
1719
1795
|
* @param {string=} key a unique key
|
|
1720
1796
|
*/
|
|
1721
|
-
set: function (
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
if (!element) { return; }
|
|
1797
|
+
set: function (element, callback, delay, key) {
|
|
1798
|
+
if (!isHTMLElement(element)) { return; }
|
|
1725
1799
|
|
|
1800
|
+
/* istanbul ignore else */
|
|
1726
1801
|
if (key && key.length) {
|
|
1802
|
+
/* istanbul ignore else */
|
|
1727
1803
|
if (!TimeCache.has(element)) {
|
|
1728
1804
|
TimeCache.set(element, new Map());
|
|
1729
1805
|
}
|
|
@@ -1736,38 +1812,35 @@
|
|
|
1736
1812
|
|
|
1737
1813
|
/**
|
|
1738
1814
|
* Returns the timer associated with the target.
|
|
1739
|
-
* @param {HTMLElement
|
|
1815
|
+
* @param {HTMLElement} element target element
|
|
1740
1816
|
* @param {string=} key a unique
|
|
1741
1817
|
* @returns {number?} the timer
|
|
1742
1818
|
*/
|
|
1743
|
-
get: function (
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
if (!element) { return null; }
|
|
1819
|
+
get: function (element, key) {
|
|
1820
|
+
if (!isHTMLElement(element)) { return null; }
|
|
1747
1821
|
var keyTimers = TimeCache.get(element);
|
|
1748
1822
|
|
|
1749
1823
|
if (key && key.length && keyTimers && keyTimers.get) {
|
|
1750
|
-
return keyTimers.get(key) || null;
|
|
1824
|
+
return keyTimers.get(key) || /* istanbul ignore next */null;
|
|
1751
1825
|
}
|
|
1752
1826
|
return keyTimers || null;
|
|
1753
1827
|
},
|
|
1754
1828
|
|
|
1755
1829
|
/**
|
|
1756
1830
|
* Clears the element's timer.
|
|
1757
|
-
* @param {HTMLElement
|
|
1831
|
+
* @param {HTMLElement} element target element
|
|
1758
1832
|
* @param {string=} key a unique key
|
|
1759
1833
|
*/
|
|
1760
|
-
clear: function (
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
if (!element) { return; }
|
|
1834
|
+
clear: function (element, key) {
|
|
1835
|
+
if (!isHTMLElement(element)) { return; }
|
|
1764
1836
|
|
|
1765
1837
|
if (key && key.length) {
|
|
1766
1838
|
var keyTimers = TimeCache.get(element);
|
|
1767
|
-
|
|
1839
|
+
/* istanbul ignore else */
|
|
1768
1840
|
if (keyTimers && keyTimers.get) {
|
|
1769
1841
|
clearTimeout(keyTimers.get(key));
|
|
1770
1842
|
keyTimers.delete(key);
|
|
1843
|
+
/* istanbul ignore else */
|
|
1771
1844
|
if (keyTimers.size === 0) {
|
|
1772
1845
|
TimeCache.delete(element);
|
|
1773
1846
|
}
|
|
@@ -1787,26 +1860,14 @@
|
|
|
1787
1860
|
*/
|
|
1788
1861
|
var toUpperCase = function (source) { return source.toUpperCase(); };
|
|
1789
1862
|
|
|
1790
|
-
/**
|
|
1791
|
-
* Utility to wrap a callback in a try() catch(e)
|
|
1792
|
-
*
|
|
1793
|
-
* @param {Function} fn callback
|
|
1794
|
-
* @param {string} origin callback context description
|
|
1795
|
-
*/
|
|
1796
|
-
function tryWrapper(fn, origin) {
|
|
1797
|
-
try { fn(); } catch (e) {
|
|
1798
|
-
throw TypeError((origin + " " + e));
|
|
1799
|
-
}
|
|
1800
|
-
}
|
|
1801
|
-
|
|
1802
1863
|
/**
|
|
1803
1864
|
* Returns the bounding client rect of a target `HTMLElement`.
|
|
1804
1865
|
*
|
|
1805
1866
|
* @see https://github.com/floating-ui/floating-ui
|
|
1806
1867
|
*
|
|
1807
|
-
* @param {HTMLElement
|
|
1868
|
+
* @param {HTMLElement} element event.target
|
|
1808
1869
|
* @param {boolean=} includeScale when *true*, the target scale is also computed
|
|
1809
|
-
* @returns {
|
|
1870
|
+
* @returns {SHORTY.BoundingClientRect} the bounding client rect object
|
|
1810
1871
|
*/
|
|
1811
1872
|
function getBoundingClientRect(element, includeScale) {
|
|
1812
1873
|
var ref = element.getBoundingClientRect();
|
|
@@ -1819,11 +1880,13 @@
|
|
|
1819
1880
|
var scaleX = 1;
|
|
1820
1881
|
var scaleY = 1;
|
|
1821
1882
|
|
|
1822
|
-
if (includeScale && element
|
|
1883
|
+
if (includeScale && isHTMLElement(element)) {
|
|
1823
1884
|
var offsetWidth = element.offsetWidth;
|
|
1824
1885
|
var offsetHeight = element.offsetHeight;
|
|
1825
|
-
scaleX = offsetWidth > 0 ? Math.round(width) / offsetWidth
|
|
1826
|
-
|
|
1886
|
+
scaleX = offsetWidth > 0 ? Math.round(width) / offsetWidth
|
|
1887
|
+
: /* istanbul ignore next */1;
|
|
1888
|
+
scaleY = offsetHeight > 0 ? Math.round(height) / offsetHeight
|
|
1889
|
+
: /* istanbul ignore next */1;
|
|
1827
1890
|
}
|
|
1828
1891
|
|
|
1829
1892
|
return {
|
|
@@ -1841,8 +1904,8 @@
|
|
|
1841
1904
|
/**
|
|
1842
1905
|
* Returns the `document.body` or the `<body>` element.
|
|
1843
1906
|
*
|
|
1844
|
-
* @param {(Node |
|
|
1845
|
-
* @returns {
|
|
1907
|
+
* @param {(Node | Window)=} node
|
|
1908
|
+
* @returns {HTMLBodyElement}
|
|
1846
1909
|
*/
|
|
1847
1910
|
function getDocumentBody(node) {
|
|
1848
1911
|
return getDocument(node).body;
|
|
@@ -1851,8 +1914,8 @@
|
|
|
1851
1914
|
/**
|
|
1852
1915
|
* Returns the `document.documentElement` or the `<html>` element.
|
|
1853
1916
|
*
|
|
1854
|
-
* @param {(Node |
|
|
1855
|
-
* @returns {
|
|
1917
|
+
* @param {(Node | Window)=} node
|
|
1918
|
+
* @returns {HTMLHtmlElement}
|
|
1856
1919
|
*/
|
|
1857
1920
|
function getDocumentElement(node) {
|
|
1858
1921
|
return getDocument(node).documentElement;
|
|
@@ -1861,8 +1924,8 @@
|
|
|
1861
1924
|
/**
|
|
1862
1925
|
* Returns the `document.head` or the `<head>` element.
|
|
1863
1926
|
*
|
|
1864
|
-
* @param {(Node |
|
|
1865
|
-
* @returns {
|
|
1927
|
+
* @param {(Node | Window)=} node
|
|
1928
|
+
* @returns {HTMLHeadElement}
|
|
1866
1929
|
*/
|
|
1867
1930
|
function getDocumentHead(node) {
|
|
1868
1931
|
return getDocument(node).head;
|
|
@@ -1874,7 +1937,7 @@
|
|
|
1874
1937
|
*
|
|
1875
1938
|
* @see https://github.com/floating-ui/floating-ui
|
|
1876
1939
|
*
|
|
1877
|
-
* @param {HTMLElement |
|
|
1940
|
+
* @param {HTMLElement | Window} element target node / element
|
|
1878
1941
|
* @returns {{x: number, y: number}} the scroll tuple
|
|
1879
1942
|
*/
|
|
1880
1943
|
function getNodeScroll(element) {
|
|
@@ -1885,44 +1948,21 @@
|
|
|
1885
1948
|
return { x: x, y: y };
|
|
1886
1949
|
}
|
|
1887
1950
|
|
|
1888
|
-
/**
|
|
1889
|
-
* Returns the `Window` object of a target node.
|
|
1890
|
-
* @see https://github.com/floating-ui/floating-ui
|
|
1891
|
-
*
|
|
1892
|
-
* @param {(Node | HTMLElement | Element | Window)=} node target node
|
|
1893
|
-
* @returns {globalThis}
|
|
1894
|
-
*/
|
|
1895
|
-
function getWindow(node) {
|
|
1896
|
-
if (node == null) {
|
|
1897
|
-
return window;
|
|
1898
|
-
}
|
|
1899
|
-
|
|
1900
|
-
if (!(node instanceof Window)) {
|
|
1901
|
-
var ownerDocument = node.ownerDocument;
|
|
1902
|
-
return ownerDocument ? ownerDocument.defaultView || window : window;
|
|
1903
|
-
}
|
|
1904
|
-
|
|
1905
|
-
// @ts-ignore
|
|
1906
|
-
return node;
|
|
1907
|
-
}
|
|
1908
|
-
|
|
1909
1951
|
/**
|
|
1910
1952
|
* Check if target is a `ShadowRoot`.
|
|
1911
1953
|
*
|
|
1912
1954
|
* @param {any} element target
|
|
1913
1955
|
* @returns {boolean} the query result
|
|
1914
1956
|
*/
|
|
1915
|
-
var isShadowRoot = function (element) {
|
|
1916
|
-
|
|
1917
|
-
return element instanceof OwnElement || element instanceof ShadowRoot;
|
|
1918
|
-
};
|
|
1957
|
+
var isShadowRoot = function (element) { return (element && element.constructor.name === 'ShadowRoot')
|
|
1958
|
+
|| false; };
|
|
1919
1959
|
|
|
1920
1960
|
/**
|
|
1921
1961
|
* Returns the `parentNode` also going through `ShadowRoot`.
|
|
1922
1962
|
* @see https://github.com/floating-ui/floating-ui
|
|
1923
1963
|
*
|
|
1924
|
-
* @param {Node
|
|
1925
|
-
* @returns {Node
|
|
1964
|
+
* @param {Node} node the target node
|
|
1965
|
+
* @returns {Node} the apropriate parent node
|
|
1926
1966
|
*/
|
|
1927
1967
|
function getParentNode(node) {
|
|
1928
1968
|
if (node.nodeName === 'HTML') {
|
|
@@ -1931,10 +1971,9 @@
|
|
|
1931
1971
|
|
|
1932
1972
|
// this is a quicker (but less type safe) way to save quite some bytes from the bundle
|
|
1933
1973
|
return (
|
|
1934
|
-
// @ts-ignore
|
|
1935
1974
|
node.assignedSlot // step into the shadow DOM of the parent of a slotted node
|
|
1936
|
-
|| node.parentNode //
|
|
1937
|
-
|| (isShadowRoot(node)
|
|
1975
|
+
|| node.parentNode // DOM Element detected
|
|
1976
|
+
|| (isShadowRoot(node) && node.host) // ShadowRoot detected
|
|
1938
1977
|
|| getDocumentElement(node) // fallback
|
|
1939
1978
|
);
|
|
1940
1979
|
}
|
|
@@ -1947,6 +1986,7 @@
|
|
|
1947
1986
|
* @returns {boolean} the query result
|
|
1948
1987
|
*/
|
|
1949
1988
|
function isScaledElement(element) {
|
|
1989
|
+
if (!element || !isHTMLElement(element)) { return false; }
|
|
1950
1990
|
var ref = getBoundingClientRect(element);
|
|
1951
1991
|
var width = ref.width;
|
|
1952
1992
|
var height = ref.height;
|
|
@@ -1960,16 +2000,17 @@
|
|
|
1960
2000
|
* Returns the rect relative to an offset parent.
|
|
1961
2001
|
* @see https://github.com/floating-ui/floating-ui
|
|
1962
2002
|
*
|
|
1963
|
-
* @param {HTMLElement
|
|
1964
|
-
* @param {
|
|
1965
|
-
* @param {{x: number, y: number}} scroll
|
|
1966
|
-
* @returns {
|
|
2003
|
+
* @param {HTMLElement} element target
|
|
2004
|
+
* @param {ParentNode | Window} offsetParent the container / offset parent
|
|
2005
|
+
* @param {{x: number, y: number}} scroll the offsetParent scroll position
|
|
2006
|
+
* @returns {SHORTY.OffsetRect}
|
|
1967
2007
|
*/
|
|
1968
2008
|
function getRectRelativeToOffsetParent(element, offsetParent, scroll) {
|
|
1969
|
-
var isParentAnElement = offsetParent
|
|
2009
|
+
var isParentAnElement = isHTMLElement(offsetParent);
|
|
1970
2010
|
var rect = getBoundingClientRect(element, isParentAnElement && isScaledElement(offsetParent));
|
|
1971
2011
|
var offsets = { x: 0, y: 0 };
|
|
1972
2012
|
|
|
2013
|
+
/* istanbul ignore next */
|
|
1973
2014
|
if (isParentAnElement) {
|
|
1974
2015
|
var offsetRect = getBoundingClientRect(offsetParent, true);
|
|
1975
2016
|
offsets.x = offsetRect.x + offsetParent.clientLeft;
|
|
@@ -1991,7 +2032,7 @@
|
|
|
1991
2032
|
/**
|
|
1992
2033
|
* Returns a unique identifier for popover, tooltip, scrollspy.
|
|
1993
2034
|
*
|
|
1994
|
-
* @param {HTMLElement
|
|
2035
|
+
* @param {HTMLElement} element target element
|
|
1995
2036
|
* @param {string=} key predefined key
|
|
1996
2037
|
* @returns {number} an existing or new unique ID
|
|
1997
2038
|
*/
|
|
@@ -2020,20 +2061,30 @@
|
|
|
2020
2061
|
}
|
|
2021
2062
|
|
|
2022
2063
|
/**
|
|
2023
|
-
*
|
|
2064
|
+
* Returns the `Window` object of a target node.
|
|
2065
|
+
* @see https://github.com/floating-ui/floating-ui
|
|
2024
2066
|
*
|
|
2025
|
-
* @param
|
|
2026
|
-
* @returns {
|
|
2067
|
+
* @param {(Node | Window)=} node target node
|
|
2068
|
+
* @returns {Window} the `Window` object
|
|
2027
2069
|
*/
|
|
2028
|
-
|
|
2070
|
+
function getWindow(node) {
|
|
2071
|
+
// node is undefined | NULL
|
|
2072
|
+
if (!node) { return window; }
|
|
2073
|
+
// node instanceof Document
|
|
2074
|
+
if (isDocument(node)) { return node.defaultView; }
|
|
2075
|
+
// node instanceof Node
|
|
2076
|
+
if (isNode(node)) { return node.ownerDocument.defaultView; }
|
|
2077
|
+
// node is instanceof Window
|
|
2078
|
+
return node;
|
|
2079
|
+
}
|
|
2029
2080
|
|
|
2030
2081
|
/**
|
|
2031
|
-
*
|
|
2082
|
+
* Shortcut for `Array.isArray()` static method.
|
|
2032
2083
|
*
|
|
2033
|
-
* @param
|
|
2084
|
+
* @param {any} arr array-like iterable object
|
|
2034
2085
|
* @returns {boolean} the query result
|
|
2035
2086
|
*/
|
|
2036
|
-
var
|
|
2087
|
+
var isArray = function (arr) { return Array.isArray(arr); };
|
|
2037
2088
|
|
|
2038
2089
|
/**
|
|
2039
2090
|
* Checks if an object is a `CustomElement`.
|
|
@@ -2041,30 +2092,44 @@
|
|
|
2041
2092
|
* @param {any} element the target object
|
|
2042
2093
|
* @returns {boolean} the query result
|
|
2043
2094
|
*/
|
|
2044
|
-
var isCustomElement = function (element) { return element && !!element.shadowRoot; };
|
|
2095
|
+
var isCustomElement = function (element) { return (element && !!element.shadowRoot) || false; };
|
|
2045
2096
|
|
|
2046
2097
|
/**
|
|
2047
2098
|
* Checks if an object is an `Element`.
|
|
2099
|
+
* @see https://dom.spec.whatwg.org/#node
|
|
2100
|
+
* ELEMENT_NODE = 1;
|
|
2101
|
+
* ATTRIBUTE_NODE = 2;
|
|
2102
|
+
* TEXT_NODE = 3;
|
|
2103
|
+
* CDATA_SECTION_NODE = 4;
|
|
2104
|
+
* ENTITY_REFERENCE_NODE = 5; // legacy
|
|
2105
|
+
* ENTITY_NODE = 6; // legacy
|
|
2106
|
+
* PROCESSING_INSTRUCTION_NODE = 7;
|
|
2107
|
+
* COMMENT_NODE = 8;
|
|
2108
|
+
* DOCUMENT_NODE = 9;
|
|
2109
|
+
* DOCUMENT_TYPE_NODE = 10;
|
|
2110
|
+
* DOCUMENT_FRAGMENT_NODE = 11;
|
|
2048
2111
|
*
|
|
2049
2112
|
* @param {any} element the target object
|
|
2050
2113
|
* @returns {boolean} the query result
|
|
2051
2114
|
*/
|
|
2052
|
-
var isElement = function (element) { return element
|
|
2115
|
+
var isElement = function (element) { return (element && [1, 2, 3, 4, 5, 6, 7, 8]
|
|
2116
|
+
.some(function (x) { return element.nodeType === x; })) || false; };
|
|
2053
2117
|
|
|
2054
2118
|
/**
|
|
2055
2119
|
* Utility to determine if an `HTMLElement`
|
|
2056
2120
|
* is partially visible in viewport.
|
|
2057
2121
|
*
|
|
2058
|
-
* @param {HTMLElement
|
|
2122
|
+
* @param {HTMLElement} element target
|
|
2059
2123
|
* @return {boolean} the query result
|
|
2060
2124
|
*/
|
|
2061
2125
|
var isElementInScrollRange = function (element) {
|
|
2126
|
+
if (!element || !isNode(element)) { return false; }
|
|
2127
|
+
|
|
2062
2128
|
var ref = getBoundingClientRect(element);
|
|
2063
2129
|
var top = ref.top;
|
|
2064
2130
|
var bottom = ref.bottom;
|
|
2065
2131
|
var ref$1 = getDocumentElement(element);
|
|
2066
2132
|
var clientHeight = ref$1.clientHeight;
|
|
2067
|
-
// checks bottom && top
|
|
2068
2133
|
return top <= clientHeight && bottom >= 0;
|
|
2069
2134
|
};
|
|
2070
2135
|
|
|
@@ -2072,18 +2137,21 @@
|
|
|
2072
2137
|
* Utility to determine if an `HTMLElement`
|
|
2073
2138
|
* is fully visible in the viewport.
|
|
2074
2139
|
*
|
|
2075
|
-
* @param {HTMLElement
|
|
2140
|
+
* @param {HTMLElement} element target
|
|
2076
2141
|
* @return {boolean} the query result
|
|
2077
2142
|
*/
|
|
2078
2143
|
var isElementInViewport = function (element) {
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
var
|
|
2082
|
-
var
|
|
2083
|
-
var
|
|
2084
|
-
var ref$1 =
|
|
2085
|
-
var
|
|
2086
|
-
var
|
|
2144
|
+
if (!element || !isNode(element)) { return false; }
|
|
2145
|
+
|
|
2146
|
+
var ref = getDocumentElement(element);
|
|
2147
|
+
var clientWidth = ref.clientWidth;
|
|
2148
|
+
var clientHeight = ref.clientHeight;
|
|
2149
|
+
var ref$1 = getBoundingClientRect(element, true);
|
|
2150
|
+
var top = ref$1.top;
|
|
2151
|
+
var left = ref$1.left;
|
|
2152
|
+
var bottom = ref$1.bottom;
|
|
2153
|
+
var right = ref$1.right;
|
|
2154
|
+
|
|
2087
2155
|
return (
|
|
2088
2156
|
top >= 0 && left >= 0
|
|
2089
2157
|
&& bottom <= clientHeight
|
|
@@ -2098,30 +2166,30 @@
|
|
|
2098
2166
|
* @returns {boolean} the query result
|
|
2099
2167
|
*/
|
|
2100
2168
|
var isElementsArray = function (object) { return Array.isArray(object)
|
|
2101
|
-
&& object.every(
|
|
2169
|
+
&& object.every(isHTMLElement); };
|
|
2102
2170
|
|
|
2103
2171
|
/**
|
|
2104
|
-
* Checks if an object is
|
|
2172
|
+
* Checks if an object is a `Function`.
|
|
2105
2173
|
*
|
|
2106
|
-
* @param {any}
|
|
2174
|
+
* @param {any} fn the target object
|
|
2107
2175
|
* @returns {boolean} the query result
|
|
2108
2176
|
*/
|
|
2109
|
-
var
|
|
2177
|
+
var isFunction = function (fn) { return (fn && fn.constructor.name === 'Function') || false; };
|
|
2110
2178
|
|
|
2111
2179
|
/**
|
|
2112
|
-
* Checks if an
|
|
2180
|
+
* Checks if an object is an `HTMLCollection`.
|
|
2113
2181
|
*
|
|
2114
|
-
* @param {any}
|
|
2182
|
+
* @param {any} object the target object
|
|
2115
2183
|
* @returns {boolean} the query result
|
|
2116
2184
|
*/
|
|
2117
|
-
var
|
|
2185
|
+
var isHTMLCollection = function (object) { return (object && object.constructor.name === 'HTMLCollection') || false; };
|
|
2118
2186
|
|
|
2119
2187
|
/**
|
|
2120
2188
|
* Check if a target element is an `<img>`.
|
|
2121
2189
|
* @param {any} element the target element
|
|
2122
2190
|
* @returns {boolean} the query result
|
|
2123
2191
|
*/
|
|
2124
|
-
var isHTMLImageElement = function (element) { return element
|
|
2192
|
+
var isHTMLImageElement = function (element) { return (element && element.tagName === 'IMG') || false; };
|
|
2125
2193
|
|
|
2126
2194
|
/**
|
|
2127
2195
|
* Checks if an element is an `<svg>` (or any type of SVG element),
|
|
@@ -2131,37 +2199,40 @@
|
|
|
2131
2199
|
* @param {any} element the target element
|
|
2132
2200
|
* @returns {boolean} the query result
|
|
2133
2201
|
*/
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
|
|
2202
|
+
|
|
2203
|
+
var isMedia = function (element) { return (
|
|
2204
|
+
element
|
|
2205
|
+
&& element.nodeType === 1
|
|
2206
|
+
&& ['SVG', 'Image', 'Video'].some(function (s) { return element.constructor.name.includes(s); })) || false; };
|
|
2137
2207
|
|
|
2138
2208
|
/**
|
|
2139
|
-
* Checks if an object is a `
|
|
2209
|
+
* Checks if an object is a `NodeList`.
|
|
2210
|
+
* => equivalent to `object instanceof NodeList`
|
|
2140
2211
|
*
|
|
2141
|
-
* @param {any}
|
|
2212
|
+
* @param {any} object the target object
|
|
2142
2213
|
* @returns {boolean} the query result
|
|
2143
2214
|
*/
|
|
2144
|
-
var
|
|
2215
|
+
var isNodeList = function (object) { return (object && object.constructor.name === 'NodeList') || false; };
|
|
2145
2216
|
|
|
2146
2217
|
/**
|
|
2147
|
-
*
|
|
2218
|
+
* Shortcut for `typeof SOMETHING === "number"`.
|
|
2148
2219
|
*
|
|
2149
|
-
* @param
|
|
2220
|
+
* @param {any} num input value
|
|
2150
2221
|
* @returns {boolean} the query result
|
|
2151
2222
|
*/
|
|
2152
|
-
var
|
|
2223
|
+
var isNumber = function (num) { return typeof num === 'number'; };
|
|
2153
2224
|
|
|
2154
2225
|
/**
|
|
2155
2226
|
* Checks if a page is Right To Left.
|
|
2156
|
-
* @param {
|
|
2227
|
+
* @param {HTMLElement=} node the target
|
|
2157
2228
|
* @returns {boolean} the query result
|
|
2158
2229
|
*/
|
|
2159
2230
|
var isRTL = function (node) { return getDocumentElement(node).dir === 'rtl'; };
|
|
2160
2231
|
|
|
2161
2232
|
/**
|
|
2162
|
-
* Shortcut for `typeof SOMETHING === string
|
|
2233
|
+
* Shortcut for `typeof SOMETHING === "string"`.
|
|
2163
2234
|
*
|
|
2164
|
-
* @param {any} str
|
|
2235
|
+
* @param {any} str input value
|
|
2165
2236
|
* @returns {boolean} the query result
|
|
2166
2237
|
*/
|
|
2167
2238
|
var isString = function (str) { return typeof str === 'string'; };
|
|
@@ -2171,24 +2242,19 @@
|
|
|
2171
2242
|
* @param {any} element the target element
|
|
2172
2243
|
* @returns {boolean} the query result
|
|
2173
2244
|
*/
|
|
2174
|
-
var isSVGElement = function (element) { return element instanceof SVGElement
|
|
2245
|
+
var isSVGElement = function (element) { return (element && element instanceof getWindow(element).SVGElement)
|
|
2246
|
+
|| false; };
|
|
2175
2247
|
|
|
2176
2248
|
/**
|
|
2177
2249
|
* Check if a target element is a `<table>`, `<td>` or `<th>`.
|
|
2250
|
+
* This specific check is important for determining
|
|
2251
|
+
* the `offsetParent` of a given element.
|
|
2252
|
+
*
|
|
2178
2253
|
* @param {any} element the target element
|
|
2179
2254
|
* @returns {boolean} the query result
|
|
2180
2255
|
*/
|
|
2181
|
-
var isTableElement = function (element) { return ['TABLE', 'TD', 'TH'].includes(element.tagName)
|
|
2182
|
-
|
|
2183
|
-
/**
|
|
2184
|
-
* Check if a target node is `window`.
|
|
2185
|
-
*
|
|
2186
|
-
* @param {any} node the target node
|
|
2187
|
-
* @returns {boolean} the query result
|
|
2188
|
-
*/
|
|
2189
|
-
function isWindow(node) {
|
|
2190
|
-
return node instanceof Window;
|
|
2191
|
-
}
|
|
2256
|
+
var isTableElement = function (element) { return (element && ['TABLE', 'TD', 'TH'].includes(element.tagName))
|
|
2257
|
+
|| false; };
|
|
2192
2258
|
|
|
2193
2259
|
/**
|
|
2194
2260
|
* Shortcut for `HTMLElement.closest` method which also works
|
|
@@ -2197,81 +2263,83 @@
|
|
|
2197
2263
|
*
|
|
2198
2264
|
* @see https://stackoverflow.com/q/54520554/803358
|
|
2199
2265
|
*
|
|
2200
|
-
* @param {HTMLElement
|
|
2266
|
+
* @param {HTMLElement} element Element to look into
|
|
2201
2267
|
* @param {string} selector the selector name
|
|
2202
|
-
* @return {
|
|
2268
|
+
* @return {HTMLElement?} the query result
|
|
2203
2269
|
*/
|
|
2204
2270
|
function closest(element, selector) {
|
|
2205
2271
|
return element ? (element.closest(selector)
|
|
2206
|
-
//
|
|
2272
|
+
// break out of `ShadowRoot`
|
|
2207
2273
|
|| closest(element.getRootNode().host, selector)) : null;
|
|
2208
2274
|
}
|
|
2209
2275
|
|
|
2276
|
+
/**
|
|
2277
|
+
* Utility to check if target is typeof `HTMLElement`, `Element`, `Node`
|
|
2278
|
+
* or find one that matches a selector.
|
|
2279
|
+
*
|
|
2280
|
+
* @param {Node | string} selector the input selector or target element
|
|
2281
|
+
* @param {ParentNode=} parent optional node to look into
|
|
2282
|
+
* @return {HTMLElement?} the `HTMLElement` or `querySelector` result
|
|
2283
|
+
*/
|
|
2284
|
+
function querySelector(selector, parent) {
|
|
2285
|
+
if (isNode(selector)) {
|
|
2286
|
+
return selector;
|
|
2287
|
+
}
|
|
2288
|
+
var lookUp = isNode(parent) ? parent : getDocument();
|
|
2289
|
+
|
|
2290
|
+
return lookUp.querySelector(selector);
|
|
2291
|
+
}
|
|
2292
|
+
|
|
2210
2293
|
/**
|
|
2211
2294
|
* Shortcut for `HTMLElement.getElementsByTagName` method. Some `Node` elements
|
|
2212
2295
|
* like `ShadowRoot` do not support `getElementsByTagName`.
|
|
2213
2296
|
*
|
|
2214
2297
|
* @param {string} selector the tag name
|
|
2215
|
-
* @param {
|
|
2216
|
-
* @return {HTMLCollectionOf<HTMLElement
|
|
2298
|
+
* @param {ParentNode=} parent optional Element to look into
|
|
2299
|
+
* @return {HTMLCollectionOf<HTMLElement>} the 'HTMLCollection'
|
|
2217
2300
|
*/
|
|
2218
2301
|
function getElementsByTagName(selector, parent) {
|
|
2219
|
-
var
|
|
2220
|
-
|
|
2221
|
-
return lookUp[method](selector);
|
|
2302
|
+
var lookUp = isNode(parent) ? parent : getDocument();
|
|
2303
|
+
return lookUp.getElementsByTagName(selector);
|
|
2222
2304
|
}
|
|
2223
2305
|
|
|
2224
|
-
/**
|
|
2225
|
-
* An `HTMLCollection` with all document elements,
|
|
2226
|
-
* which is the equivalent of `document.all`.
|
|
2227
|
-
*/
|
|
2228
|
-
var documentAll = getElementsByTagName('*');
|
|
2229
|
-
|
|
2230
|
-
/**
|
|
2231
|
-
* A global array with `Element` | `HTMLElement`.
|
|
2232
|
-
*/
|
|
2233
|
-
var elementNodes = [Element, HTMLElement];
|
|
2234
|
-
|
|
2235
|
-
/**
|
|
2236
|
-
* A global array of possible `ParentNode`.
|
|
2237
|
-
*/
|
|
2238
|
-
var parentNodes = [Document, Element, HTMLElement];
|
|
2239
|
-
|
|
2240
2306
|
/**
|
|
2241
2307
|
* Returns an `Array` of `Node` elements that are registered as
|
|
2242
2308
|
* `CustomElement`.
|
|
2243
2309
|
* @see https://stackoverflow.com/questions/27334365/how-to-get-list-of-registered-custom-elements
|
|
2244
2310
|
*
|
|
2245
|
-
* @param {
|
|
2246
|
-
* @returns {Array<HTMLElement
|
|
2311
|
+
* @param {ParentNode=} parent parent to look into
|
|
2312
|
+
* @returns {Array<HTMLElement>} the query result
|
|
2247
2313
|
*/
|
|
2248
2314
|
function getCustomElements(parent) {
|
|
2249
|
-
var collection =
|
|
2250
|
-
|
|
2315
|
+
var collection = getElementsByTagName('*', parent);
|
|
2316
|
+
|
|
2251
2317
|
return [].concat( collection ).filter(isCustomElement);
|
|
2252
2318
|
}
|
|
2253
2319
|
|
|
2254
2320
|
/**
|
|
2255
2321
|
* Returns an `Element` that matches the id in the document.
|
|
2322
|
+
* Within multiple <iframe> elements, a `parent` parameter
|
|
2323
|
+
* would decisively locate the correct element.
|
|
2256
2324
|
*
|
|
2257
2325
|
* @param {string} id
|
|
2258
|
-
* @
|
|
2326
|
+
* @param {ParentNode=} context
|
|
2327
|
+
* @returns {HTMLElement?}
|
|
2259
2328
|
*/
|
|
2260
|
-
function getElementById(id) {
|
|
2261
|
-
return getDocument().getElementById(id);
|
|
2329
|
+
function getElementById(id, context) {
|
|
2330
|
+
return getDocument(context).getElementById(id);
|
|
2262
2331
|
}
|
|
2263
2332
|
|
|
2264
2333
|
/**
|
|
2265
2334
|
* A shortcut for `(document|Element).querySelectorAll`.
|
|
2266
2335
|
*
|
|
2267
2336
|
* @param {string} selector the input selector
|
|
2268
|
-
* @param {
|
|
2269
|
-
* @return {NodeListOf<HTMLElement
|
|
2337
|
+
* @param {ParentNode=} parent optional node to look into
|
|
2338
|
+
* @return {NodeListOf<HTMLElement>} the query result
|
|
2270
2339
|
*/
|
|
2271
2340
|
function querySelectorAll(selector, parent) {
|
|
2272
|
-
var
|
|
2273
|
-
|
|
2274
|
-
return lookUp[method](selector);
|
|
2341
|
+
var lookUp = isNode(parent) ? parent : getDocument();
|
|
2342
|
+
return lookUp.querySelectorAll(selector);
|
|
2275
2343
|
}
|
|
2276
2344
|
|
|
2277
2345
|
/**
|
|
@@ -2279,19 +2347,18 @@
|
|
|
2279
2347
|
* like `ShadowRoot` do not support `getElementsByClassName`.
|
|
2280
2348
|
*
|
|
2281
2349
|
* @param {string} selector the class name
|
|
2282
|
-
* @param {
|
|
2283
|
-
* @return {HTMLCollectionOf<HTMLElement
|
|
2350
|
+
* @param {ParentNode=} parent optional Element to look into
|
|
2351
|
+
* @return {HTMLCollectionOf<HTMLElement>} the 'HTMLCollection'
|
|
2284
2352
|
*/
|
|
2285
2353
|
function getElementsByClassName(selector, parent) {
|
|
2286
|
-
var
|
|
2287
|
-
|
|
2288
|
-
return lookUp[method](selector);
|
|
2354
|
+
var lookUp = isNode(parent) ? parent : getDocument();
|
|
2355
|
+
return lookUp.getElementsByClassName(selector);
|
|
2289
2356
|
}
|
|
2290
2357
|
|
|
2291
2358
|
/**
|
|
2292
2359
|
* Check if element matches a CSS selector.
|
|
2293
2360
|
*
|
|
2294
|
-
* @param {HTMLElement
|
|
2361
|
+
* @param {HTMLElement} target
|
|
2295
2362
|
* @param {string} selector
|
|
2296
2363
|
* @returns {boolean}
|
|
2297
2364
|
*/
|
|
@@ -2299,15 +2366,15 @@
|
|
|
2299
2366
|
return target.matches(selector);
|
|
2300
2367
|
}
|
|
2301
2368
|
|
|
2302
|
-
// @ts-nocheck
|
|
2303
2369
|
var ElementProto = Element.prototype;
|
|
2370
|
+
|
|
2304
2371
|
var matchesFn = ElementProto.matches
|
|
2305
|
-
|| ElementProto.matchesSelector
|
|
2306
|
-
|| ElementProto.webkitMatchesSelector
|
|
2307
|
-
|| ElementProto.mozMatchesSelector
|
|
2308
|
-
|| ElementProto.msMatchesSelector
|
|
2309
|
-
|| ElementProto.oMatchesSelector
|
|
2310
|
-
|| function matchesNotSupported() {
|
|
2372
|
+
|| /* istanbul ignore next */ ElementProto.matchesSelector
|
|
2373
|
+
|| /* istanbul ignore next */ ElementProto.webkitMatchesSelector
|
|
2374
|
+
|| /* istanbul ignore next */ ElementProto.mozMatchesSelector
|
|
2375
|
+
|| /* istanbul ignore next */ ElementProto.msMatchesSelector
|
|
2376
|
+
|| /* istanbul ignore next */ ElementProto.oMatchesSelector
|
|
2377
|
+
|| /* istanbul ignore next */ function matchesNotSupported() {
|
|
2311
2378
|
return false;
|
|
2312
2379
|
};
|
|
2313
2380
|
|
|
@@ -2315,7 +2382,7 @@
|
|
|
2315
2382
|
* Check if element matches a CSS selector,
|
|
2316
2383
|
* supporting a range of legacy browsers.
|
|
2317
2384
|
*
|
|
2318
|
-
* @param {HTMLElement
|
|
2385
|
+
* @param {HTMLElement} target
|
|
2319
2386
|
* @param {string} selector
|
|
2320
2387
|
* @returns {boolean}
|
|
2321
2388
|
*/
|
|
@@ -2323,9 +2390,7 @@
|
|
|
2323
2390
|
return matchesFn.call(target, selector);
|
|
2324
2391
|
}
|
|
2325
2392
|
|
|
2326
|
-
var version = "1.0.
|
|
2327
|
-
|
|
2328
|
-
// @ts-ignore
|
|
2393
|
+
var version = "1.0.3";
|
|
2329
2394
|
|
|
2330
2395
|
/**
|
|
2331
2396
|
* A global namespace for library version.
|
|
@@ -2333,9 +2398,9 @@
|
|
|
2333
2398
|
*/
|
|
2334
2399
|
var Version = version;
|
|
2335
2400
|
|
|
2336
|
-
|
|
2401
|
+
/** @typedef {import('../types/index')} */
|
|
2337
2402
|
|
|
2338
|
-
var
|
|
2403
|
+
var SHORTY = {
|
|
2339
2404
|
ariaChecked: ariaChecked,
|
|
2340
2405
|
ariaDescription: ariaDescription,
|
|
2341
2406
|
ariaDescribedBy: ariaDescribedBy,
|
|
@@ -2501,6 +2566,7 @@
|
|
|
2501
2566
|
isCustomElement: isCustomElement,
|
|
2502
2567
|
isElement: isElement,
|
|
2503
2568
|
isNode: isNode,
|
|
2569
|
+
isNumber: isNumber,
|
|
2504
2570
|
isHTMLElement: isHTMLElement,
|
|
2505
2571
|
isHTMLImageElement: isHTMLImageElement,
|
|
2506
2572
|
isSVGElement: isSVGElement,
|
|
@@ -2511,13 +2577,12 @@
|
|
|
2511
2577
|
isShadowRoot: isShadowRoot,
|
|
2512
2578
|
isDocument: isDocument,
|
|
2513
2579
|
isElementsArray: isElementsArray,
|
|
2580
|
+
isFunction: isFunction,
|
|
2581
|
+
isObject: isObject,
|
|
2514
2582
|
isWindow: isWindow,
|
|
2515
2583
|
isMedia: isMedia,
|
|
2516
2584
|
isRTL: isRTL,
|
|
2517
|
-
elementNodes: elementNodes,
|
|
2518
|
-
parentNodes: parentNodes,
|
|
2519
2585
|
closest: closest,
|
|
2520
|
-
documentAll: documentAll,
|
|
2521
2586
|
querySelector: querySelector,
|
|
2522
2587
|
getCustomElements: getCustomElements,
|
|
2523
2588
|
getElementById: getElementById,
|
|
@@ -2528,7 +2593,6 @@
|
|
|
2528
2593
|
matchesLegacy: matches,
|
|
2529
2594
|
normalizeValue: normalizeValue,
|
|
2530
2595
|
normalizeOptions: normalizeOptions,
|
|
2531
|
-
tryWrapper: tryWrapper,
|
|
2532
2596
|
reflow: reflow,
|
|
2533
2597
|
noop: noop,
|
|
2534
2598
|
focus: focus,
|
|
@@ -2537,6 +2601,7 @@
|
|
|
2537
2601
|
Float32ArrayFrom: Float32ArrayFrom,
|
|
2538
2602
|
Float64ArrayFrom: Float64ArrayFrom,
|
|
2539
2603
|
ObjectAssign: ObjectAssign,
|
|
2604
|
+
ObjectEntries: ObjectEntries,
|
|
2540
2605
|
ObjectKeys: ObjectKeys,
|
|
2541
2606
|
ObjectValues: ObjectValues,
|
|
2542
2607
|
OriginalEvent: OriginalEvent,
|
|
@@ -2558,6 +2623,6 @@
|
|
|
2558
2623
|
Version: Version,
|
|
2559
2624
|
};
|
|
2560
2625
|
|
|
2561
|
-
return
|
|
2626
|
+
return SHORTY;
|
|
2562
2627
|
|
|
2563
2628
|
}));
|