@oscarpalmer/toretto 0.30.0 → 0.31.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/attribute/index.js +5 -5
- package/dist/event/delegation.js +10 -10
- package/dist/find/index.js +1 -1
- package/dist/find/relative.js +13 -14
- package/dist/html/index.js +11 -8
- package/dist/html/sanitize.js +29 -14
- package/dist/internal/attribute.js +5 -5
- package/dist/is.js +3 -3
- package/dist/style.js +2 -2
- package/dist/toretto.full.js +102 -236
- package/package.json +6 -6
- package/src/attribute/get.ts +4 -12
- package/src/attribute/index.ts +5 -5
- package/src/attribute/set.ts +13 -13
- package/src/data.ts +7 -16
- package/src/event/delegation.ts +10 -10
- package/src/find/index.ts +1 -1
- package/src/find/relative.ts +19 -23
- package/src/html/index.ts +13 -12
- package/src/html/sanitize.ts +58 -31
- package/src/internal/attribute.ts +9 -9
- package/src/internal/element-value.ts +3 -4
- package/src/internal/get-value.ts +5 -8
- package/src/internal/is.ts +1 -3
- package/src/is.ts +4 -4
- package/src/models.ts +0 -5
- package/src/style.ts +12 -15
- package/types/attribute/get.d.ts +3 -3
- package/types/attribute/set.d.ts +9 -9
- package/types/data.d.ts +4 -5
- package/types/internal/attribute.d.ts +7 -7
- package/types/internal/element-value.d.ts +2 -3
- package/types/internal/get-value.d.ts +2 -3
- package/types/internal/is.d.ts +1 -2
- package/types/models.d.ts +0 -4
- package/types/style.d.ts +7 -7
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type {PlainObject} from '@oscarpalmer/atoms';
|
|
2
2
|
import {isPlainObject} from '@oscarpalmer/atoms/is';
|
|
3
3
|
import {getString} from '@oscarpalmer/atoms/string';
|
|
4
|
-
import type {Attribute,
|
|
4
|
+
import type {Attribute, Property} from '../models';
|
|
5
5
|
import {isHTMLOrSVGElement} from './is';
|
|
6
6
|
|
|
7
7
|
function badAttributeHandler(name?: string, value?: string): boolean {
|
|
@@ -82,11 +82,11 @@ function isAttribute(value: unknown): value is Attr | Attribute {
|
|
|
82
82
|
);
|
|
83
83
|
}
|
|
84
84
|
|
|
85
|
-
export function
|
|
85
|
+
export function _isBadAttribute(first: unknown, second: unknown, decode: boolean): boolean {
|
|
86
86
|
return handleAttribute(badAttributeHandler, decode, first, second);
|
|
87
87
|
}
|
|
88
88
|
|
|
89
|
-
export function
|
|
89
|
+
export function _isBooleanAttribute(first: unknown, decode: boolean): boolean {
|
|
90
90
|
return handleAttribute(
|
|
91
91
|
name => booleanAttributesSet.has(name?.toLowerCase() as string),
|
|
92
92
|
decode,
|
|
@@ -95,7 +95,7 @@ export function isBooleanAttribute(first: unknown, decode: boolean): boolean {
|
|
|
95
95
|
);
|
|
96
96
|
}
|
|
97
97
|
|
|
98
|
-
export function
|
|
98
|
+
export function _isEmptyNonBooleanAttribute(
|
|
99
99
|
first: unknown,
|
|
100
100
|
second: unknown,
|
|
101
101
|
decode: boolean,
|
|
@@ -109,7 +109,7 @@ export function isEmptyNonBooleanAttribute(
|
|
|
109
109
|
);
|
|
110
110
|
}
|
|
111
111
|
|
|
112
|
-
export function
|
|
112
|
+
export function _isInvalidBooleanAttribute(
|
|
113
113
|
first: unknown,
|
|
114
114
|
second: unknown,
|
|
115
115
|
decode: boolean,
|
|
@@ -125,7 +125,7 @@ function isValidSourceAttribute(name: string, value: string): boolean {
|
|
|
125
125
|
return EXPRESSION_SOURCE_NAME.test(name) && EXPRESSION_SOURCE_VALUE.test(value);
|
|
126
126
|
}
|
|
127
127
|
|
|
128
|
-
function updateAttribute(element:
|
|
128
|
+
function updateAttribute(element: Element, name: string, value: unknown): void {
|
|
129
129
|
const isBoolean = booleanAttributesSet.has(name.toLowerCase());
|
|
130
130
|
|
|
131
131
|
if (isBoolean) {
|
|
@@ -139,14 +139,14 @@ function updateAttribute(element: HTMLOrSVGElement, name: string, value: unknown
|
|
|
139
139
|
}
|
|
140
140
|
}
|
|
141
141
|
|
|
142
|
-
function updateProperty(element:
|
|
142
|
+
function updateProperty(element: Element, name: string, value: unknown): void {
|
|
143
143
|
const actual = name.toLowerCase();
|
|
144
144
|
|
|
145
145
|
(element as unknown as PlainObject)[actual] =
|
|
146
146
|
value === '' || (typeof value === 'string' && value.toLowerCase() === actual) || value === true;
|
|
147
147
|
}
|
|
148
148
|
|
|
149
|
-
export function updateValue(element:
|
|
149
|
+
export function updateValue(element: Element, first: unknown, second: unknown): void {
|
|
150
150
|
if (!isHTMLOrSVGElement(element)) {
|
|
151
151
|
return;
|
|
152
152
|
}
|
|
@@ -159,7 +159,7 @@ export function updateValue(element: HTMLOrSVGElement, first: unknown, second: u
|
|
|
159
159
|
}
|
|
160
160
|
|
|
161
161
|
export function updateValues(
|
|
162
|
-
element:
|
|
162
|
+
element: Element,
|
|
163
163
|
values: Attribute<unknown>[] | Record<string, unknown>,
|
|
164
164
|
): void {
|
|
165
165
|
if (!isHTMLOrSVGElement(element)) {
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import type {PlainObject} from '@oscarpalmer/atoms';
|
|
2
2
|
import {isNullableOrWhitespace, isPlainObject} from '@oscarpalmer/atoms/is';
|
|
3
3
|
import {isHTMLOrSVGElement} from '../is';
|
|
4
|
-
import type {HTMLOrSVGElement} from '../models';
|
|
5
4
|
|
|
6
5
|
export function setElementValues(
|
|
7
|
-
element:
|
|
6
|
+
element: Element,
|
|
8
7
|
first: PlainObject | string,
|
|
9
8
|
second: unknown,
|
|
10
|
-
callback: (element:
|
|
9
|
+
callback: (element: Element, key: string, value: unknown) => void,
|
|
11
10
|
): void {
|
|
12
11
|
if (!isHTMLOrSVGElement(element)) {
|
|
13
12
|
return;
|
|
@@ -28,7 +27,7 @@ export function setElementValues(
|
|
|
28
27
|
}
|
|
29
28
|
|
|
30
29
|
export function updateElementValue(
|
|
31
|
-
element:
|
|
30
|
+
element: Element,
|
|
32
31
|
key: string,
|
|
33
32
|
value: unknown,
|
|
34
33
|
set: (key: string, value: string) => void,
|
|
@@ -1,15 +1,10 @@
|
|
|
1
1
|
import {camelCase, kebabCase, parse} from '@oscarpalmer/atoms/string';
|
|
2
|
-
import type {HTMLOrSVGElement} from '../models';
|
|
3
2
|
|
|
4
3
|
export function getBoolean(value: unknown, defaultValue?: boolean): boolean {
|
|
5
4
|
return typeof value === 'boolean' ? value : (defaultValue ?? false);
|
|
6
5
|
}
|
|
7
6
|
|
|
8
|
-
export function getAttributeValue(
|
|
9
|
-
element: HTMLOrSVGElement,
|
|
10
|
-
name: string,
|
|
11
|
-
parseValue: boolean,
|
|
12
|
-
): unknown {
|
|
7
|
+
export function getAttributeValue(element: Element, name: string, parseValue: boolean): unknown {
|
|
13
8
|
const normalized = kebabCase(name);
|
|
14
9
|
const attribute = element.attributes[normalized as keyof NamedNodeMap];
|
|
15
10
|
const value = attribute instanceof Attr ? attribute.value : undefined;
|
|
@@ -20,13 +15,15 @@ export function getAttributeValue(
|
|
|
20
15
|
}
|
|
21
16
|
|
|
22
17
|
export function getStyleValue(
|
|
23
|
-
element:
|
|
18
|
+
element: Element,
|
|
24
19
|
property: string,
|
|
25
20
|
computed: boolean,
|
|
26
21
|
): string | undefined {
|
|
27
22
|
const name = camelCase(property);
|
|
28
23
|
|
|
29
|
-
return computed
|
|
24
|
+
return computed
|
|
25
|
+
? getComputedStyle(element)[name as never]
|
|
26
|
+
: (element as HTMLElement).style[name as never];
|
|
30
27
|
}
|
|
31
28
|
|
|
32
29
|
export const EXPRESSION_DATA_PREFIX = /^data-/i;
|
package/src/internal/is.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import type {HTMLOrSVGElement} from '../models';
|
|
2
|
-
|
|
3
1
|
/**
|
|
4
2
|
* Is the value an event target?
|
|
5
3
|
* @param value Value to check
|
|
@@ -20,6 +18,6 @@ export function isEventTarget(value: unknown): value is EventTarget {
|
|
|
20
18
|
* @param value Value to check
|
|
21
19
|
* @returns `true` if it's an HTML or SVG element, otherwise `false`
|
|
22
20
|
*/
|
|
23
|
-
export function isHTMLOrSVGElement(value: unknown): value is
|
|
21
|
+
export function isHTMLOrSVGElement(value: unknown): value is HTMLElement | SVGElement {
|
|
24
22
|
return value instanceof HTMLElement || value instanceof SVGElement;
|
|
25
23
|
}
|
package/src/is.ts
CHANGED
|
@@ -22,18 +22,18 @@ export function isInDocument(node: Node): boolean;
|
|
|
22
22
|
*/
|
|
23
23
|
export function isInDocument(node: Node, document: Document): boolean;
|
|
24
24
|
|
|
25
|
-
export function isInDocument(node: Node,
|
|
25
|
+
export function isInDocument(node: Node, doc?: Document): boolean {
|
|
26
26
|
if (!(node instanceof Node)) {
|
|
27
27
|
return false;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
if (!(
|
|
30
|
+
if (!(doc instanceof Document)) {
|
|
31
31
|
return node.ownerDocument?.contains(node) ?? true;
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
return node.ownerDocument == null
|
|
35
|
-
? node ===
|
|
36
|
-
: node.ownerDocument ===
|
|
35
|
+
? node === doc
|
|
36
|
+
: node.ownerDocument === doc && doc.contains(node);
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
//
|
package/src/models.ts
CHANGED
package/src/style.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {setElementValues, updateElementValue} from './internal/element-value';
|
|
2
2
|
import {getStyleValue} from './internal/get-value';
|
|
3
3
|
import {isHTMLOrSVGElement} from './internal/is';
|
|
4
|
-
import type {
|
|
4
|
+
import type {TextDirection} from './models';
|
|
5
5
|
|
|
6
6
|
export type StyleToggler = {
|
|
7
7
|
/**
|
|
@@ -22,7 +22,7 @@ export type StyleToggler = {
|
|
|
22
22
|
* @returns Style value
|
|
23
23
|
*/
|
|
24
24
|
export function getStyle(
|
|
25
|
-
element:
|
|
25
|
+
element: Element,
|
|
26
26
|
property: keyof CSSStyleDeclaration,
|
|
27
27
|
computed?: boolean,
|
|
28
28
|
): string | undefined {
|
|
@@ -41,7 +41,7 @@ export function getStyle(
|
|
|
41
41
|
* @returns Style values
|
|
42
42
|
*/
|
|
43
43
|
export function getStyles<Property extends keyof CSSStyleDeclaration>(
|
|
44
|
-
element:
|
|
44
|
+
element: Element,
|
|
45
45
|
properties: Property[],
|
|
46
46
|
computed?: boolean,
|
|
47
47
|
): Record<Property, string | undefined> {
|
|
@@ -70,7 +70,7 @@ export function getStyles<Property extends keyof CSSStyleDeclaration>(
|
|
|
70
70
|
* @param computed Get the computed text direction? _(defaults to `false`)_
|
|
71
71
|
* @returns Text direction
|
|
72
72
|
*/
|
|
73
|
-
export function getTextDirection(element:
|
|
73
|
+
export function getTextDirection(element: Element, computed?: boolean): TextDirection {
|
|
74
74
|
if (!(element instanceof Element)) {
|
|
75
75
|
return undefined as never;
|
|
76
76
|
}
|
|
@@ -93,7 +93,7 @@ export function getTextDirection(element: HTMLOrSVGElement, computed?: boolean):
|
|
|
93
93
|
* @param value Style value
|
|
94
94
|
*/
|
|
95
95
|
export function setStyle(
|
|
96
|
-
element:
|
|
96
|
+
element: Element,
|
|
97
97
|
property: keyof CSSStyleDeclaration,
|
|
98
98
|
value?: string,
|
|
99
99
|
): void {
|
|
@@ -105,7 +105,7 @@ export function setStyle(
|
|
|
105
105
|
* @param element Element to set the styles on
|
|
106
106
|
* @param styles Styles to set
|
|
107
107
|
*/
|
|
108
|
-
export function setStyles(element:
|
|
108
|
+
export function setStyles(element: Element, styles: Partial<CSSStyleDeclaration>): void {
|
|
109
109
|
setElementValues(element, styles as never, null, updateStyleProperty);
|
|
110
110
|
}
|
|
111
111
|
|
|
@@ -115,10 +115,7 @@ export function setStyles(element: HTMLOrSVGElement, styles: Partial<CSSStyleDec
|
|
|
115
115
|
* @param styles Styles to be set or removed
|
|
116
116
|
* @returns Style toggler
|
|
117
117
|
*/
|
|
118
|
-
export function toggleStyles(
|
|
119
|
-
element: HTMLOrSVGElement,
|
|
120
|
-
styles: Partial<CSSStyleDeclaration>,
|
|
121
|
-
): StyleToggler {
|
|
118
|
+
export function toggleStyles(element: Element, styles: Partial<CSSStyleDeclaration>): StyleToggler {
|
|
122
119
|
function toggle(set: boolean): void {
|
|
123
120
|
hasSet = set;
|
|
124
121
|
|
|
@@ -160,16 +157,16 @@ export function toggleStyles(
|
|
|
160
157
|
};
|
|
161
158
|
}
|
|
162
159
|
|
|
163
|
-
function updateStyleProperty(element:
|
|
160
|
+
function updateStyleProperty(element: Element, key: string, value: unknown): void {
|
|
164
161
|
updateElementValue(
|
|
165
162
|
element,
|
|
166
163
|
key,
|
|
167
164
|
value,
|
|
168
|
-
function (this:
|
|
169
|
-
this.style[property as never] =
|
|
165
|
+
function (this: Element, property: string, style: string) {
|
|
166
|
+
(this as HTMLElement).style[property as never] = style;
|
|
170
167
|
},
|
|
171
|
-
function (this:
|
|
172
|
-
this.style[property as never] = '';
|
|
168
|
+
function (this: Element, property: string) {
|
|
169
|
+
(this as HTMLElement).style[property as never] = '';
|
|
173
170
|
},
|
|
174
171
|
false,
|
|
175
172
|
);
|
package/types/attribute/get.d.ts
CHANGED
|
@@ -5,14 +5,14 @@
|
|
|
5
5
|
* @param parse Parse value? _(defaults to `true`)_
|
|
6
6
|
* @returns Attribute value _(or `undefined`)_
|
|
7
7
|
*/
|
|
8
|
-
export declare function getAttribute(element:
|
|
8
|
+
export declare function getAttribute(element: Element, name: `data-${string}`, parse?: boolean): unknown;
|
|
9
9
|
/**
|
|
10
10
|
* Get the value of a specific attribute from an element
|
|
11
11
|
* @param element Element to get attribute from
|
|
12
12
|
* @param name Attribute name
|
|
13
13
|
* @returns Attribute value _(or `undefined`)_
|
|
14
14
|
*/
|
|
15
|
-
export declare function getAttribute(element:
|
|
15
|
+
export declare function getAttribute(element: Element, name: string): unknown;
|
|
16
16
|
/**
|
|
17
17
|
* Get specific attributes from an element
|
|
18
18
|
* @param element Element to get attributes from
|
|
@@ -20,4 +20,4 @@ export declare function getAttribute(element: HTMLOrSVGElement, name: string): u
|
|
|
20
20
|
* @param parseData Parse data values? _(defaults to `true`)_
|
|
21
21
|
* @returns Object of named attributes
|
|
22
22
|
*/
|
|
23
|
-
export declare function getAttributes<Key extends string>(element:
|
|
23
|
+
export declare function getAttributes<Key extends string>(element: Element, names: Key[], parseData?: boolean): Record<Key, unknown>;
|
package/types/attribute/set.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Attribute,
|
|
1
|
+
import type { Attribute, Property } from '../models';
|
|
2
2
|
/**
|
|
3
3
|
* Set an attribute on an element
|
|
4
4
|
*
|
|
@@ -7,7 +7,7 @@ import type { Attribute, HTMLOrSVGElement, Property } from '../models';
|
|
|
7
7
|
* @param name Attribute name
|
|
8
8
|
* @param value Attribute value
|
|
9
9
|
*/
|
|
10
|
-
export declare function setAttribute(element:
|
|
10
|
+
export declare function setAttribute(element: Element, name: string, value?: unknown): void;
|
|
11
11
|
/**
|
|
12
12
|
* Set an attribute on an element
|
|
13
13
|
*
|
|
@@ -15,7 +15,7 @@ export declare function setAttribute(element: HTMLOrSVGElement, name: string, va
|
|
|
15
15
|
* @param element Element for attribute
|
|
16
16
|
* @param attribute Attribute to set
|
|
17
17
|
*/
|
|
18
|
-
export declare function setAttribute(element:
|
|
18
|
+
export declare function setAttribute(element: Element, attribute: Attr | Attribute): void;
|
|
19
19
|
/**
|
|
20
20
|
* Set one or more attributes on an element
|
|
21
21
|
*
|
|
@@ -23,7 +23,7 @@ export declare function setAttribute(element: HTMLOrSVGElement, attribute: Attr
|
|
|
23
23
|
* @param element Element for attributes
|
|
24
24
|
* @param attributes Attributes to set
|
|
25
25
|
*/
|
|
26
|
-
export declare function setAttributes(element:
|
|
26
|
+
export declare function setAttributes(element: Element, attributes: Array<Attr | Attribute>): void;
|
|
27
27
|
/**
|
|
28
28
|
* Set one or more attributes on an element
|
|
29
29
|
*
|
|
@@ -31,7 +31,7 @@ export declare function setAttributes(element: HTMLOrSVGElement, attributes: Arr
|
|
|
31
31
|
* @param element Element for attributes
|
|
32
32
|
* @param attributes Attributes to set
|
|
33
33
|
*/
|
|
34
|
-
export declare function setAttributes(element:
|
|
34
|
+
export declare function setAttributes(element: Element, attributes: Record<string, unknown>): void;
|
|
35
35
|
/**
|
|
36
36
|
* Set a property on an element
|
|
37
37
|
*
|
|
@@ -40,7 +40,7 @@ export declare function setAttributes(element: HTMLOrSVGElement, attributes: Rec
|
|
|
40
40
|
* @param name Property name
|
|
41
41
|
* @param value Property value
|
|
42
42
|
*/
|
|
43
|
-
export declare function setProperty(element:
|
|
43
|
+
export declare function setProperty(element: Element, name: string, value: boolean | string): void;
|
|
44
44
|
/**
|
|
45
45
|
* Set a property on an element
|
|
46
46
|
*
|
|
@@ -48,7 +48,7 @@ export declare function setProperty(element: HTMLOrSVGElement, name: string, val
|
|
|
48
48
|
* @param element Element for property
|
|
49
49
|
* @param property Property to set
|
|
50
50
|
*/
|
|
51
|
-
export declare function setProperty(element:
|
|
51
|
+
export declare function setProperty(element: Element, property: Property): void;
|
|
52
52
|
/**
|
|
53
53
|
* Set one or more properties on an element
|
|
54
54
|
*
|
|
@@ -56,7 +56,7 @@ export declare function setProperty(element: HTMLOrSVGElement, property: Propert
|
|
|
56
56
|
* @param element Element for properties
|
|
57
57
|
* @param properties Properties to set
|
|
58
58
|
*/
|
|
59
|
-
export declare function setProperties(element:
|
|
59
|
+
export declare function setProperties(element: Element, properties: Property[]): void;
|
|
60
60
|
/**
|
|
61
61
|
* Set one or more properties on an element
|
|
62
62
|
*
|
|
@@ -64,4 +64,4 @@ export declare function setProperties(element: HTMLOrSVGElement, properties: Pro
|
|
|
64
64
|
* @param element Element for properties
|
|
65
65
|
* @param properties Properties to set
|
|
66
66
|
*/
|
|
67
|
-
export declare function setProperties(element:
|
|
67
|
+
export declare function setProperties(element: Element, properties: Record<string, unknown>): void;
|
package/types/data.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { PlainObject } from '@oscarpalmer/atoms';
|
|
2
|
-
import type { HTMLOrSVGElement } from './models';
|
|
3
2
|
/**
|
|
4
3
|
* Get a keyed data value from an element
|
|
5
4
|
* @param element Element to get data from
|
|
@@ -7,7 +6,7 @@ import type { HTMLOrSVGElement } from './models';
|
|
|
7
6
|
* @param parse Parse values? _(defaults to `true`)_
|
|
8
7
|
* @returns Data value
|
|
9
8
|
*/
|
|
10
|
-
export declare function getData(element:
|
|
9
|
+
export declare function getData(element: Element, key: string, parse?: boolean): unknown;
|
|
11
10
|
/**
|
|
12
11
|
* Get keyed data values from an element
|
|
13
12
|
* @param element Element to get data from
|
|
@@ -15,17 +14,17 @@ export declare function getData(element: HTMLOrSVGElement, key: string, parse?:
|
|
|
15
14
|
* @param parse Parse values? _(defaults to `true`)_
|
|
16
15
|
* @returns Keyed data values
|
|
17
16
|
*/
|
|
18
|
-
export declare function getData<Key extends string>(element:
|
|
17
|
+
export declare function getData<Key extends string>(element: Element, keys: Key[], parse?: boolean): Record<Key, unknown>;
|
|
19
18
|
/**
|
|
20
19
|
* Set data values on an element
|
|
21
20
|
* @param element Element to set data on
|
|
22
21
|
* @param data Data to set
|
|
23
22
|
*/
|
|
24
|
-
export declare function setData(element:
|
|
23
|
+
export declare function setData(element: Element, data: PlainObject): void;
|
|
25
24
|
/**
|
|
26
25
|
* Set a data value on an element
|
|
27
26
|
* @param element Element to set data on
|
|
28
27
|
* @param key Data key
|
|
29
28
|
* @param value Data value
|
|
30
29
|
*/
|
|
31
|
-
export declare function setData(element:
|
|
30
|
+
export declare function setData(element: Element, key: string, value: unknown): void;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import type { Attribute,
|
|
2
|
-
export declare function
|
|
3
|
-
export declare function
|
|
4
|
-
export declare function
|
|
5
|
-
export declare function
|
|
1
|
+
import type { Attribute, Property } from '../models';
|
|
2
|
+
export declare function _isBadAttribute(first: unknown, second: unknown, decode: boolean): boolean;
|
|
3
|
+
export declare function _isBooleanAttribute(first: unknown, decode: boolean): boolean;
|
|
4
|
+
export declare function _isEmptyNonBooleanAttribute(first: unknown, second: unknown, decode: boolean): boolean;
|
|
5
|
+
export declare function _isInvalidBooleanAttribute(first: unknown, second: unknown, decode: boolean): boolean;
|
|
6
6
|
export declare function isProperty(value: unknown): value is Property;
|
|
7
|
-
export declare function updateValue(element:
|
|
8
|
-
export declare function updateValues(element:
|
|
7
|
+
export declare function updateValue(element: Element, first: unknown, second: unknown): void;
|
|
8
|
+
export declare function updateValues(element: Element, values: Attribute<unknown>[] | Record<string, unknown>): void;
|
|
9
9
|
/**
|
|
10
10
|
* List of boolean attributes
|
|
11
11
|
*/
|
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
import type { PlainObject } from '@oscarpalmer/atoms';
|
|
2
|
-
|
|
3
|
-
export declare function
|
|
4
|
-
export declare function updateElementValue(element: HTMLOrSVGElement, key: string, value: unknown, set: (key: string, value: string) => void, remove: (key: string) => void, json: boolean): void;
|
|
2
|
+
export declare function setElementValues(element: Element, first: PlainObject | string, second: unknown, callback: (element: Element, key: string, value: unknown) => void): void;
|
|
3
|
+
export declare function updateElementValue(element: Element, key: string, value: unknown, set: (key: string, value: string) => void, remove: (key: string) => void, json: boolean): void;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import type { HTMLOrSVGElement } from '../models';
|
|
2
1
|
export declare function getBoolean(value: unknown, defaultValue?: boolean): boolean;
|
|
3
|
-
export declare function getAttributeValue(element:
|
|
4
|
-
export declare function getStyleValue(element:
|
|
2
|
+
export declare function getAttributeValue(element: Element, name: string, parseValue: boolean): unknown;
|
|
3
|
+
export declare function getStyleValue(element: Element, property: string, computed: boolean): string | undefined;
|
|
5
4
|
export declare const EXPRESSION_DATA_PREFIX: RegExp;
|
package/types/internal/is.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { HTMLOrSVGElement } from '../models';
|
|
2
1
|
/**
|
|
3
2
|
* Is the value an event target?
|
|
4
3
|
* @param value Value to check
|
|
@@ -10,4 +9,4 @@ export declare function isEventTarget(value: unknown): value is EventTarget;
|
|
|
10
9
|
* @param value Value to check
|
|
11
10
|
* @returns `true` if it's an HTML or SVG element, otherwise `false`
|
|
12
11
|
*/
|
|
13
|
-
export declare function isHTMLOrSVGElement(value: unknown): value is
|
|
12
|
+
export declare function isHTMLOrSVGElement(value: unknown): value is HTMLElement | SVGElement;
|
package/types/models.d.ts
CHANGED
package/types/style.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { TextDirection } from './models';
|
|
2
2
|
export type StyleToggler = {
|
|
3
3
|
/**
|
|
4
4
|
* Set the provided styles on the element
|
|
@@ -16,7 +16,7 @@ export type StyleToggler = {
|
|
|
16
16
|
* @param computed Get the computed style? _(defaults to `false`)_
|
|
17
17
|
* @returns Style value
|
|
18
18
|
*/
|
|
19
|
-
export declare function getStyle(element:
|
|
19
|
+
export declare function getStyle(element: Element, property: keyof CSSStyleDeclaration, computed?: boolean): string | undefined;
|
|
20
20
|
/**
|
|
21
21
|
* Get styles from an element
|
|
22
22
|
* @param element Element to get the styles from
|
|
@@ -24,31 +24,31 @@ export declare function getStyle(element: HTMLOrSVGElement, property: keyof CSSS
|
|
|
24
24
|
* @param computed Get the computed styles? _(defaults to `false`)_
|
|
25
25
|
* @returns Style values
|
|
26
26
|
*/
|
|
27
|
-
export declare function getStyles<Property extends keyof CSSStyleDeclaration>(element:
|
|
27
|
+
export declare function getStyles<Property extends keyof CSSStyleDeclaration>(element: Element, properties: Property[], computed?: boolean): Record<Property, string | undefined>;
|
|
28
28
|
/**
|
|
29
29
|
* Get the text direction of an element
|
|
30
30
|
* @param element Element to get the text direction from
|
|
31
31
|
* @param computed Get the computed text direction? _(defaults to `false`)_
|
|
32
32
|
* @returns Text direction
|
|
33
33
|
*/
|
|
34
|
-
export declare function getTextDirection(element:
|
|
34
|
+
export declare function getTextDirection(element: Element, computed?: boolean): TextDirection;
|
|
35
35
|
/**
|
|
36
36
|
* Set a style on an element
|
|
37
37
|
* @param element Element to set the style on
|
|
38
38
|
* @param property Style name
|
|
39
39
|
* @param value Style value
|
|
40
40
|
*/
|
|
41
|
-
export declare function setStyle(element:
|
|
41
|
+
export declare function setStyle(element: Element, property: keyof CSSStyleDeclaration, value?: string): void;
|
|
42
42
|
/**
|
|
43
43
|
* Set styles on an element
|
|
44
44
|
* @param element Element to set the styles on
|
|
45
45
|
* @param styles Styles to set
|
|
46
46
|
*/
|
|
47
|
-
export declare function setStyles(element:
|
|
47
|
+
export declare function setStyles(element: Element, styles: Partial<CSSStyleDeclaration>): void;
|
|
48
48
|
/**
|
|
49
49
|
* Toggle styles for an element
|
|
50
50
|
* @param element Element to style
|
|
51
51
|
* @param styles Styles to be set or removed
|
|
52
52
|
* @returns Style toggler
|
|
53
53
|
*/
|
|
54
|
-
export declare function toggleStyles(element:
|
|
54
|
+
export declare function toggleStyles(element: Element, styles: Partial<CSSStyleDeclaration>): StyleToggler;
|