@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
|
@@ -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 {
|
|
8
|
-
* @return {NodeListOf<HTMLElement
|
|
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
|
|
12
|
-
|
|
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'
|
|
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'
|
|
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'
|
|
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'
|
|
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']
|
|
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'
|
|
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'
|
|
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'
|
|
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'
|
|
11
|
-
|
|
10
|
+
const transitionProperty = 'webkitTransition' in documentHead.style ? 'webkitTransitionProperty'
|
|
11
|
+
: /* istanbul ignore next */'transitionProperty';
|
|
12
12
|
export default transitionProperty;
|
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
|
|
245
|
+
relatedTarget: EventTarget | null;
|
|
241
246
|
}
|
|
242
247
|
|
|
243
248
|
export interface OffsetRect {
|
package/types/module/shorty.ts
CHANGED
|
@@ -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';
|