@oscarpalmer/toretto 0.27.0 → 0.28.0
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/dist/event/delegation.js +18 -19
- package/dist/toretto.full.js +49 -89
- package/package.json +5 -4
- package/src/attribute/set.ts +10 -44
- package/src/data.ts +3 -15
- package/src/event/delegation.ts +29 -35
- package/src/event/index.ts +5 -23
- package/src/find/index.ts +10 -26
- package/src/find/relative.ts +4 -16
- package/src/focusable.ts +15 -51
- package/src/html.ts +10 -37
- package/src/internal/attribute.ts +11 -45
- package/src/internal/element-value.ts +0 -1
- package/src/internal/get-value.ts +2 -6
- package/src/internal/sanitize.ts +3 -14
- package/src/is.ts +1 -1
- package/src/style.ts +4 -18
- package/src/touch.ts +2 -6
|
@@ -14,9 +14,7 @@ export function getAttributeValue(
|
|
|
14
14
|
const attribute = element.attributes[normalized as keyof NamedNodeMap];
|
|
15
15
|
const value = attribute instanceof Attr ? attribute.value : undefined;
|
|
16
16
|
|
|
17
|
-
return EXPRESSION_DATA_PREFIX.test(normalized) &&
|
|
18
|
-
typeof value === 'string' &&
|
|
19
|
-
parseValue
|
|
17
|
+
return EXPRESSION_DATA_PREFIX.test(normalized) && typeof value === 'string' && parseValue
|
|
20
18
|
? (parse(value) ?? value)
|
|
21
19
|
: value;
|
|
22
20
|
}
|
|
@@ -28,9 +26,7 @@ export function getStyleValue(
|
|
|
28
26
|
): string | undefined {
|
|
29
27
|
const name = camelCase(property);
|
|
30
28
|
|
|
31
|
-
return computed
|
|
32
|
-
? getComputedStyle(element)[name as never]
|
|
33
|
-
: element.style[name as never];
|
|
29
|
+
return computed ? getComputedStyle(element)[name as never] : element.style[name as never];
|
|
34
30
|
}
|
|
35
31
|
|
|
36
32
|
export const EXPRESSION_DATA_PREFIX = /^data-/i;
|
package/src/internal/sanitize.ts
CHANGED
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
import {isPlainObject} from '@oscarpalmer/atoms/is';
|
|
2
|
-
import {
|
|
3
|
-
isBadAttribute,
|
|
4
|
-
isEmptyNonBooleanAttribute,
|
|
5
|
-
isInvalidBooleanAttribute,
|
|
6
|
-
} from './attribute';
|
|
2
|
+
import {isBadAttribute, isEmptyNonBooleanAttribute, isInvalidBooleanAttribute} from './attribute';
|
|
7
3
|
|
|
8
4
|
//
|
|
9
5
|
|
|
@@ -31,11 +27,7 @@ export function getSanitizeOptions(input?: SanitizeOptions): Options {
|
|
|
31
27
|
return options as Options;
|
|
32
28
|
}
|
|
33
29
|
|
|
34
|
-
export function sanitizeAttributes(
|
|
35
|
-
element: Element,
|
|
36
|
-
attributes: Attr[],
|
|
37
|
-
options: Options,
|
|
38
|
-
): void {
|
|
30
|
+
export function sanitizeAttributes(element: Element, attributes: Attr[], options: Options): void {
|
|
39
31
|
const {length} = attributes;
|
|
40
32
|
|
|
41
33
|
for (let index = 0; index < length; index += 1) {
|
|
@@ -43,10 +35,7 @@ export function sanitizeAttributes(
|
|
|
43
35
|
|
|
44
36
|
if (isBadAttribute(attribute) || isEmptyNonBooleanAttribute(attribute)) {
|
|
45
37
|
element.removeAttribute(attribute.name);
|
|
46
|
-
} else if (
|
|
47
|
-
options.sanitizeBooleanAttributes &&
|
|
48
|
-
isInvalidBooleanAttribute(attribute)
|
|
49
|
-
) {
|
|
38
|
+
} else if (options.sanitizeBooleanAttributes && isInvalidBooleanAttribute(attribute)) {
|
|
50
39
|
element.setAttribute(attribute.name, '');
|
|
51
40
|
}
|
|
52
41
|
}
|
package/src/is.ts
CHANGED
package/src/style.ts
CHANGED
|
@@ -57,11 +57,7 @@ export function getStyles<Property extends keyof CSSStyleDeclaration>(
|
|
|
57
57
|
const property = properties[index];
|
|
58
58
|
|
|
59
59
|
if (typeof property === 'string') {
|
|
60
|
-
styles[property] = getStyleValue(
|
|
61
|
-
element,
|
|
62
|
-
property,
|
|
63
|
-
computed === true,
|
|
64
|
-
) as never;
|
|
60
|
+
styles[property] = getStyleValue(element, property, computed === true) as never;
|
|
65
61
|
}
|
|
66
62
|
}
|
|
67
63
|
|
|
@@ -74,10 +70,7 @@ export function getStyles<Property extends keyof CSSStyleDeclaration>(
|
|
|
74
70
|
* @param computed Get the computed text direction? _(defaults to `false`)_
|
|
75
71
|
* @returns Text direction
|
|
76
72
|
*/
|
|
77
|
-
export function getTextDirection(
|
|
78
|
-
element: HTMLOrSVGElement,
|
|
79
|
-
computed?: boolean,
|
|
80
|
-
): TextDirection {
|
|
73
|
+
export function getTextDirection(element: HTMLOrSVGElement, computed?: boolean): TextDirection {
|
|
81
74
|
if (!(element instanceof Element)) {
|
|
82
75
|
return undefined as never;
|
|
83
76
|
}
|
|
@@ -112,10 +105,7 @@ export function setStyle(
|
|
|
112
105
|
* @param element Element to set the styles on
|
|
113
106
|
* @param styles Styles to set
|
|
114
107
|
*/
|
|
115
|
-
export function setStyles(
|
|
116
|
-
element: HTMLOrSVGElement,
|
|
117
|
-
styles: Partial<CSSStyleDeclaration>,
|
|
118
|
-
): void {
|
|
108
|
+
export function setStyles(element: HTMLOrSVGElement, styles: Partial<CSSStyleDeclaration>): void {
|
|
119
109
|
setElementValues(element, styles as never, null, updateStyleProperty);
|
|
120
110
|
}
|
|
121
111
|
|
|
@@ -170,11 +160,7 @@ export function toggleStyles(
|
|
|
170
160
|
};
|
|
171
161
|
}
|
|
172
162
|
|
|
173
|
-
function updateStyleProperty(
|
|
174
|
-
element: HTMLOrSVGElement,
|
|
175
|
-
key: string,
|
|
176
|
-
value: unknown,
|
|
177
|
-
): void {
|
|
163
|
+
function updateStyleProperty(element: HTMLOrSVGElement, key: string, value: unknown): void {
|
|
178
164
|
updateElementValue(
|
|
179
165
|
element,
|
|
180
166
|
key,
|
package/src/touch.ts
CHANGED
|
@@ -36,16 +36,12 @@ function getSupport(): boolean {
|
|
|
36
36
|
return true;
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
if (
|
|
40
|
-
typeof navigator.maxTouchPoints === 'number' &&
|
|
41
|
-
navigator.maxTouchPoints > 0
|
|
42
|
-
) {
|
|
39
|
+
if (typeof navigator.maxTouchPoints === 'number' && navigator.maxTouchPoints > 0) {
|
|
43
40
|
return true;
|
|
44
41
|
}
|
|
45
42
|
|
|
46
43
|
if (
|
|
47
|
-
typeof (navigator as NavigatorWithMsMaxTouchPoints).msMaxTouchPoints ===
|
|
48
|
-
'number' &&
|
|
44
|
+
typeof (navigator as NavigatorWithMsMaxTouchPoints).msMaxTouchPoints === 'number' &&
|
|
49
45
|
(navigator as NavigatorWithMsMaxTouchPoints).msMaxTouchPoints > 0
|
|
50
46
|
) {
|
|
51
47
|
return true;
|