@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.
Files changed (116) hide show
  1. package/README.md +14 -8
  2. package/dist/shorty.esm.js +388 -329
  3. package/dist/shorty.esm.min.js +2 -2
  4. package/dist/shorty.js +401 -336
  5. package/dist/shorty.min.js +2 -2
  6. package/package.json +12 -3
  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 +2 -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 +12 -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 +12 -12
  49. package/src/index.js +12 -10
  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/isObject.js +8 -0
  66. package/src/is/isRTL.js +1 -1
  67. package/src/is/isSVGElement.js +4 -1
  68. package/src/is/isScaledElement.js +2 -0
  69. package/src/is/isShadowRoot.js +2 -5
  70. package/src/is/isString.js +2 -2
  71. package/src/is/isTableElement.js +5 -1
  72. package/src/is/isWindow.js +5 -5
  73. package/src/misc/ObjectEntries.js +7 -0
  74. package/src/misc/OriginalEvent.js +4 -2
  75. package/src/misc/createElement.js +3 -1
  76. package/src/misc/createElementNS.js +7 -3
  77. package/src/misc/data.js +16 -16
  78. package/src/misc/dispatchEvent.js +1 -1
  79. package/src/misc/emulateAnimationEnd.js +5 -2
  80. package/src/misc/emulateAnimationEndLegacy.js +9 -6
  81. package/src/misc/emulateTransitionEnd.js +5 -2
  82. package/src/misc/emulateTransitionEndLegacy.js +9 -6
  83. package/src/misc/focus.js +1 -2
  84. package/src/misc/normalizeOptions.js +2 -2
  85. package/src/misc/normalizeValue.js +8 -6
  86. package/src/misc/passiveHandlerLegacy.js +2 -1
  87. package/src/misc/reflow.js +1 -2
  88. package/src/misc/setElementStyle.js +12 -3
  89. package/src/misc/timer.js +16 -19
  90. package/src/misc/version.js +0 -1
  91. package/src/selectors/closest.js +3 -3
  92. package/src/selectors/getCustomElements.js +4 -6
  93. package/src/selectors/getElementById.js +6 -3
  94. package/src/selectors/getElementsByClassName.js +5 -5
  95. package/src/selectors/getElementsByTagName.js +5 -5
  96. package/src/selectors/matches.js +1 -1
  97. package/src/selectors/matchesLegacy.js +8 -8
  98. package/src/selectors/querySelector.js +10 -6
  99. package/src/selectors/querySelectorAll.js +5 -5
  100. package/src/strings/animationDelayLegacy.js +2 -1
  101. package/src/strings/animationDurationLegacy.js +2 -1
  102. package/src/strings/animationEndEventLegacy.js +2 -1
  103. package/src/strings/animationNameLegacy.js +2 -1
  104. package/src/strings/mouseHoverEvents.js +2 -1
  105. package/src/strings/transitionDelayLegacy.js +2 -1
  106. package/src/strings/transitionDurationLegacy.js +2 -1
  107. package/src/strings/transitionEndEventLegacy.js +2 -1
  108. package/src/strings/transitionPropertyLegacy.js +2 -2
  109. package/src/strings/userAgentData.js +0 -1
  110. package/types/index.d.ts +10 -5
  111. package/types/module/shorty.ts +3 -4
  112. package/types/shorty.d.ts +248 -249
  113. package/src/misc/tryWrapper.js +0 -11
  114. package/src/selectors/documentAll.js +0 -8
  115. package/src/selectors/elementNodes.js +0 -5
  116. package/src/selectors/parentNodes.js +0 -5
@@ -1,14 +1,14 @@
1
1
  import getDocument from '../get/getDocument';
2
+ import isNode from '../is/isNode';
2
3
 
3
4
  /**
4
5
  * A shortcut for `(document|Element).querySelectorAll`.
5
6
  *
6
7
  * @param {string} selector the input selector
7
- * @param {(HTMLElement | Element | Document | Node)=} parent optional node to look into
8
- * @return {NodeListOf<HTMLElement | Element>} the query result
8
+ * @param {ParentNode=} parent optional node to look into
9
+ * @return {NodeListOf<HTMLElement>} the query result
9
10
  */
10
11
  export default function querySelectorAll(selector, parent) {
11
- const method = 'querySelectorAll';
12
- const lookUp = parent && parent[method] ? parent : getDocument();
13
- return lookUp[method](selector);
12
+ const lookUp = isNode(parent) ? parent : getDocument();
13
+ return lookUp.querySelectorAll(selector);
14
14
  }
@@ -4,5 +4,6 @@ import documentHead from '../blocks/documentHead';
4
4
  * A global namespace for 'animationDelay' string.
5
5
  * @type {string}
6
6
  */
7
- const animationDelay = 'webkitAnimation' in documentHead.style ? 'webkitAnimationDelay' : 'animationDelay';
7
+ const animationDelay = 'webkitAnimation' in documentHead.style ? 'webkitAnimationDelay'
8
+ : /* istanbul ignore next */'animationDelay';
8
9
  export default animationDelay;
@@ -4,5 +4,6 @@ import documentHead from '../blocks/documentHead';
4
4
  * A global namespace for 'animationDuration' string.
5
5
  * @type {string}
6
6
  */
7
- const animationDuration = 'webkitAnimation' in documentHead.style ? 'webkitAnimationDuration' : 'animationDuration';
7
+ const animationDuration = 'webkitAnimation' in documentHead.style ? 'webkitAnimationDuration'
8
+ : /* istanbul ignore next */'animationDuration';
8
9
  export default animationDuration;
@@ -4,5 +4,6 @@ import documentHead from '../blocks/documentHead';
4
4
  * A global namespace for 'animationend' string.
5
5
  * @type {string}
6
6
  */
7
- const animationEndEvent = 'webkitAnimation' in documentHead.style ? 'webkitAnimationEnd' : 'animationend';
7
+ const animationEndEvent = 'webkitAnimation' in documentHead.style ? 'webkitAnimationEnd'
8
+ : /* istanbul ignore next */'animationend';
8
9
  export default animationEndEvent;
@@ -4,5 +4,6 @@ import documentHead from '../blocks/documentHead';
4
4
  * A global namespace for 'animationName' string.
5
5
  * @type {string}
6
6
  */
7
- const animationName = 'webkitAnimation' in documentHead.style ? 'webkitAnimationName' : 'animationName';
7
+ const animationName = 'webkitAnimation' in documentHead.style ? 'webkitAnimationName'
8
+ : /* istanbul ignore next */'animationName';
8
9
  export default animationName;
@@ -2,5 +2,6 @@
2
2
  * A global namespace for mouse hover events.
3
3
  * @type {[string, string]}
4
4
  */
5
- const mouseHoverEvents = ('onmouseleave' in document) ? ['mouseenter', 'mouseleave'] : ['mouseover', 'mouseout'];
5
+ const mouseHoverEvents = ('onmouseleave' in document) ? ['mouseenter', 'mouseleave']
6
+ : /* istanbul ignore next */['mouseover', 'mouseout'];
6
7
  export default mouseHoverEvents;
@@ -4,5 +4,6 @@ import documentHead from '../blocks/documentHead';
4
4
  * A global namespace for 'transitionDelay' string.
5
5
  * @type {string}
6
6
  */
7
- const transitionDelay = 'webkitTransition' in documentHead.style ? 'webkitTransitionDelay' : 'transitionDelay';
7
+ const transitionDelay = 'webkitTransition' in documentHead.style ? 'webkitTransitionDelay'
8
+ : /* istanbul ignore next */'transitionDelay';
8
9
  export default transitionDelay;
@@ -4,5 +4,6 @@ import documentHead from '../blocks/documentHead';
4
4
  * A global namespace for 'transitionDuration' string.
5
5
  * @type {string}
6
6
  */
7
- const transitionDuration = 'webkitTransition' in documentHead.style ? 'webkitTransitionDuration' : 'transitionDuration';
7
+ const transitionDuration = 'webkitTransition' in documentHead.style ? 'webkitTransitionDuration'
8
+ : /* istanbul ignore next */'transitionDuration';
8
9
  export default transitionDuration;
@@ -4,5 +4,6 @@ import documentHead from '../blocks/documentHead';
4
4
  * A global namespace for 'transitionend' string.
5
5
  * @type {string}
6
6
  */
7
- const transitionEndEvent = 'webkitTransition' in documentHead.style ? 'webkitTransitionEnd' : 'transitionend';
7
+ const transitionEndEvent = 'webkitTransition' in documentHead.style ? 'webkitTransitionEnd'
8
+ : /* istanbul ignore next */'transitionend';
8
9
  export default transitionEndEvent;
@@ -7,6 +7,6 @@ import documentHead from '../blocks/documentHead';
7
7
  *
8
8
  * @type {string}
9
9
  */
10
- const transitionProperty = 'webkitTransition' in documentHead.style ? 'webkitTransitionProperty' : 'transitionProperty';
11
-
10
+ const transitionProperty = 'webkitTransition' in documentHead.style ? 'webkitTransitionProperty'
11
+ : /* istanbul ignore next */'transitionProperty';
12
12
  export default transitionProperty;
@@ -1,4 +1,3 @@
1
- // @ts-ignore
2
1
  const { userAgentData: uaDATA } = navigator;
3
2
 
4
3
  /**
package/types/index.d.ts CHANGED
@@ -174,13 +174,13 @@ export { default as passiveHandler } from 'shorty/src/misc/passiveHandler';
174
174
  export { default as setElementStyle } from 'shorty/src/misc/setElementStyle';
175
175
  export { default as normalizeValue } from 'shorty/src/misc/normalizeValue';
176
176
  export { default as normalizeOptions } from 'shorty/src/misc/normalizeOptions';
177
- export { default as tryWrapper } from 'shorty/src/misc/tryWrapper';
178
177
  export { default as reflow } from 'shorty/src/misc/reflow';
179
178
  export { default as focus } from 'shorty/src/misc/focus';
180
179
  export { default as noop } from 'shorty/src/misc/noop';
181
180
  export { default as ArrayFrom } from 'shorty/src/misc/ArrayFrom';
182
181
  export { default as Float32ArrayFrom } from 'shorty/src/misc/Float32ArrayFrom';
183
182
  export { default as Float64ArrayFrom } from 'shorty/src/misc/Float64ArrayFrom';
183
+ export { default as ObjectEntries } from 'shorty/src/misc/ObjectEntries';
184
184
  export { default as ObjectKeys } from 'shorty/src/misc/ObjectKeys';
185
185
  export { default as ObjectValues } from 'shorty/src/misc/ObjectValues';
186
186
  export { default as ObjectAssign } from 'shorty/src/misc/ObjectAssign';
@@ -201,6 +201,7 @@ export { default as isHTMLImageElement } from 'shorty/src/is/isHTMLImageElement'
201
201
  export { default as isMedia } from 'shorty/src/is/isMedia';
202
202
  export { default as isNode } from 'shorty/src/is/isNode';
203
203
  export { default as isNodeList } from 'shorty/src/is/isNodeList';
204
+ export { default as isObject } from 'shorty/src/is/isObject';
204
205
  export { default as isRTL } from 'shorty/src/is/isRTL';
205
206
  export { default as isScaledElement } from 'shorty/src/is/isScaledElement';
206
207
  export { default as isShadowRoot } from 'shorty/src/is/isShadowRoot';
@@ -208,10 +209,7 @@ export { default as isString } from 'shorty/src/is/isString';
208
209
  export { default as isSVGElement } from 'shorty/src/is/isSVGElement';
209
210
  export { default as isTableElement } from 'shorty/src/is/isTableElement';
210
211
  export { default as isWindow } from 'shorty/src/is/isWindow';
211
- export { default as parentNodes } from 'shorty/src/selectors/parentNodes';
212
- export { default as elementNodes } from 'shorty/src/selectors/elementNodes';
213
212
  export { default as closest } from 'shorty/src/selectors/closest';
214
- export { default as documentAll } from 'shorty/src/selectors/documentAll';
215
213
  export { default as getCustomElements } from 'shorty/src/selectors/getCustomElements';
216
214
  export { default as getElementById } from 'shorty/src/selectors/getElementById';
217
215
  export { default as querySelector } from 'shorty/src/selectors/querySelector';
@@ -236,8 +234,15 @@ export interface BoundingClientRect {
236
234
  y: number,
237
235
  }
238
236
 
237
+ export type OnOff<T> = (
238
+ element: T,
239
+ eventType: string,
240
+ listener: EventListenerObject['handleEvent'],
241
+ options?: AddEventListenerOptions
242
+ ) => void;
243
+
239
244
  export interface OriginalEvent extends CustomEvent {
240
- relatedTarget?: HTMLElement | Element | null;
245
+ relatedTarget: EventTarget | null;
241
246
  }
242
247
 
243
248
  export interface OffsetRect {
@@ -193,7 +193,6 @@ export { default as passiveHandlerLegacy } from '../../src/misc/passiveHandlerLe
193
193
  export { default as setElementStyle } from '../../src/misc/setElementStyle';
194
194
  export { default as normalizeValue } from '../../src/misc/normalizeValue';
195
195
  export { default as normalizeOptions } from '../../src/misc/normalizeOptions';
196
- export { default as tryWrapper } from '../../src/misc/tryWrapper';
197
196
  export { default as reflow } from '../../src/misc/reflow';
198
197
  export { default as focus } from '../../src/misc/focus';
199
198
  export { default as noop } from '../../src/misc/noop';
@@ -204,6 +203,7 @@ export { default as toUpperCase } from '../../src/misc/toUpperCase';
204
203
  export { default as ArrayFrom } from '../../src/misc/ArrayFrom';
205
204
  export { default as Float32ArrayFrom } from '../../src/misc/Float32ArrayFrom';
206
205
  export { default as Float64ArrayFrom } from '../../src/misc/Float64ArrayFrom';
206
+ export { default as ObjectEntries } from '../../src/misc/ObjectEntries';
207
207
  export { default as ObjectKeys } from '../../src/misc/ObjectKeys';
208
208
  export { default as ObjectValues } from '../../src/misc/ObjectValues';
209
209
  export { default as ObjectAssign } from '../../src/misc/ObjectAssign';
@@ -224,19 +224,18 @@ export { default as isHTMLImageElement } from '../../src/is/isHTMLImageElement';
224
224
  export { default as isMedia } from '../../src/is/isMedia';
225
225
  export { default as isNode } from '../../src/is/isNode';
226
226
  export { default as isNodeList } from '../../src/is/isNodeList';
227
+ export { default as isObject } from '../../src/is/isObject';
227
228
  export { default as isRTL } from '../../src/is/isRTL';
228
229
  export { default as isScaledElement } from '../../src/is/isScaledElement';
229
230
  export { default as isShadowRoot } from '../../src/is/isShadowRoot';
230
231
  export { default as isString } from '../../src/is/isString';
232
+ export { default as isNumber } from '../../src/is/isNumber';
231
233
  export { default as isSVGElement } from '../../src/is/isSVGElement';
232
234
  export { default as isTableElement } from '../../src/is/isTableElement';
233
235
  export { default as isWindow } from '../../src/is/isWindow';
234
236
 
235
237
  // selectors
236
- export { default as elementNodes } from '../../src/selectors/elementNodes';
237
- export { default as parentNodes } from '../../src/selectors/parentNodes';
238
238
  export { default as closest } from '../../src/selectors/closest';
239
- export { default as documentAll } from '../../src/selectors/documentAll';
240
239
  export { default as getCustomElements } from '../../src/selectors/getCustomElements';
241
240
  export { default as getElementById } from '../../src/selectors/getElementById';
242
241
  export { default as querySelector } from '../../src/selectors/querySelector';