@oscarpalmer/toretto 0.12.0 → 0.13.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.js +37 -12
- package/dist/attribute.mjs +37 -12
- package/dist/event.js +8 -13
- package/dist/event.mjs +4 -13
- package/dist/find.js +3 -2
- package/dist/find.mjs +3 -2
- package/dist/focusable.js +1 -1
- package/dist/focusable.mjs +1 -1
- package/dist/index.js +62 -28
- package/dist/index.mjs +1 -0
- package/dist/internal/get-value.js +7 -0
- package/dist/internal/get-value.mjs +7 -0
- package/dist/is.js +15 -0
- package/dist/is.mjs +15 -0
- package/package.json +15 -15
- package/src/attribute.ts +127 -34
- package/src/data.ts +9 -8
- package/src/event.ts +18 -34
- package/src/find.ts +8 -3
- package/src/focusable.ts +1 -4
- package/src/html.ts +3 -3
- package/src/index.ts +1 -1
- package/src/internal/element-value.ts +4 -3
- package/src/internal/get-value.ts +3 -0
- package/src/is.ts +49 -0
- package/src/models.ts +10 -8
- package/src/style.ts +9 -9
- package/types/attribute.d.ts +23 -7
- package/types/data.d.ts +5 -4
- package/types/event.d.ts +6 -11
- package/types/find.d.ts +4 -0
- package/types/html.d.ts +3 -3
- package/types/index.d.cts +71 -33
- package/types/index.d.ts +1 -0
- package/types/internal/element-value.d.ts +3 -2
- package/types/internal/get-value.d.ts +1 -0
- package/types/is.d.ts +22 -0
- package/types/models.d.ts +7 -7
- package/types/style.d.ts +5 -5
package/dist/attribute.js
CHANGED
|
@@ -37,29 +37,52 @@ function isInvalidBooleanAttribute(attribute) {
|
|
|
37
37
|
return !(normalised.length === 0 || normalised === attribute.name || attribute.name === "hidden" && normalised === "until-found");
|
|
38
38
|
}
|
|
39
39
|
function setAttribute(element, first, second) {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
40
|
+
updateValue(element, first, second, updateAttribute);
|
|
41
|
+
}
|
|
42
|
+
function setAttributes(element, attributes) {
|
|
43
|
+
updateValues(element, attributes);
|
|
44
|
+
}
|
|
45
|
+
function setProperty(element, first, second) {
|
|
46
|
+
updateValue(element, first, second, updateProperty);
|
|
45
47
|
}
|
|
46
|
-
function
|
|
47
|
-
|
|
48
|
+
function setProperties(element, properties) {
|
|
49
|
+
updateValues(element, properties, updateProperty);
|
|
50
|
+
}
|
|
51
|
+
function updateAttribute(element, name, value2) {
|
|
52
|
+
const normalised = name.toLowerCase();
|
|
53
|
+
if (booleanAttributes.includes(normalised)) {
|
|
54
|
+
updateProperty(element, name, value2, false);
|
|
55
|
+
} else if (value2 == null) {
|
|
48
56
|
element.removeAttribute(name);
|
|
49
57
|
} else {
|
|
50
58
|
element.setAttribute(name, typeof value2 === "string" ? value2 : getString(value2));
|
|
51
59
|
}
|
|
52
60
|
}
|
|
53
|
-
function
|
|
54
|
-
const
|
|
55
|
-
|
|
61
|
+
function updateProperty(element, name, value2, validate) {
|
|
62
|
+
const actual = validate ?? true ? name.toLowerCase() : name;
|
|
63
|
+
if (actual === "hidden") {
|
|
64
|
+
element.hidden = typeof value2 === "string" && value2.toLowerCase() === "until-found" ? "until-found" : value2 === "" || value2 === true;
|
|
65
|
+
} else {
|
|
66
|
+
element[actual] = value2 === "" || typeof value2 === "string" && value2.toLowerCase() === actual || value2 === true;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
function updateValue(element, first, second, callback) {
|
|
70
|
+
if (isPlainObject(first) && typeof first?.name === "string") {
|
|
71
|
+
callback(element, first.name, first.value);
|
|
72
|
+
} else if (typeof first === "string") {
|
|
73
|
+
callback(element, first, second);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
function updateValues(element, values, callback) {
|
|
77
|
+
const isArray = Array.isArray(values);
|
|
78
|
+
const entries = Object.entries(values);
|
|
56
79
|
const { length } = entries;
|
|
57
80
|
for (let index = 0;index < length; index += 1) {
|
|
58
81
|
const entry = entries[index];
|
|
59
82
|
if (isArray) {
|
|
60
|
-
|
|
83
|
+
(callback ?? updateAttribute)(element, entry[1].name, entry[1].value);
|
|
61
84
|
} else {
|
|
62
|
-
|
|
85
|
+
(callback ?? updateAttribute)(element, entry[0], entry[1]);
|
|
63
86
|
}
|
|
64
87
|
}
|
|
65
88
|
}
|
|
@@ -93,6 +116,8 @@ var onPrefix = /^on/i;
|
|
|
93
116
|
var sourcePrefix = /^(href|src|xlink:href)$/i;
|
|
94
117
|
var valuePrefix = /(data:text\/html|javascript:)/i;
|
|
95
118
|
export {
|
|
119
|
+
setProperty,
|
|
120
|
+
setProperties,
|
|
96
121
|
setAttributes,
|
|
97
122
|
setAttribute,
|
|
98
123
|
isInvalidBooleanAttribute,
|
package/dist/attribute.mjs
CHANGED
|
@@ -18,29 +18,52 @@ function isInvalidBooleanAttribute(attribute) {
|
|
|
18
18
|
return !(normalised.length === 0 || normalised === attribute.name || attribute.name === "hidden" && normalised === "until-found");
|
|
19
19
|
}
|
|
20
20
|
function setAttribute(element, first, second) {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
21
|
+
updateValue(element, first, second, updateAttribute);
|
|
22
|
+
}
|
|
23
|
+
function setAttributes(element, attributes) {
|
|
24
|
+
updateValues(element, attributes);
|
|
25
|
+
}
|
|
26
|
+
function setProperty(element, first, second) {
|
|
27
|
+
updateValue(element, first, second, updateProperty);
|
|
26
28
|
}
|
|
27
|
-
function
|
|
28
|
-
|
|
29
|
+
function setProperties(element, properties) {
|
|
30
|
+
updateValues(element, properties, updateProperty);
|
|
31
|
+
}
|
|
32
|
+
function updateAttribute(element, name, value) {
|
|
33
|
+
const normalised = name.toLowerCase();
|
|
34
|
+
if (booleanAttributes.includes(normalised)) {
|
|
35
|
+
updateProperty(element, name, value, false);
|
|
36
|
+
} else if (value == null) {
|
|
29
37
|
element.removeAttribute(name);
|
|
30
38
|
} else {
|
|
31
39
|
element.setAttribute(name, typeof value === "string" ? value : getString(value));
|
|
32
40
|
}
|
|
33
41
|
}
|
|
34
|
-
function
|
|
35
|
-
const
|
|
36
|
-
|
|
42
|
+
function updateProperty(element, name, value, validate) {
|
|
43
|
+
const actual = validate ?? true ? name.toLowerCase() : name;
|
|
44
|
+
if (actual === "hidden") {
|
|
45
|
+
element.hidden = typeof value === "string" && value.toLowerCase() === "until-found" ? "until-found" : value === "" || value === true;
|
|
46
|
+
} else {
|
|
47
|
+
element[actual] = value === "" || typeof value === "string" && value.toLowerCase() === actual || value === true;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
function updateValue(element, first, second, callback) {
|
|
51
|
+
if (isPlainObject(first) && typeof first?.name === "string") {
|
|
52
|
+
callback(element, first.name, first.value);
|
|
53
|
+
} else if (typeof first === "string") {
|
|
54
|
+
callback(element, first, second);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
function updateValues(element, values, callback) {
|
|
58
|
+
const isArray = Array.isArray(values);
|
|
59
|
+
const entries = Object.entries(values);
|
|
37
60
|
const { length } = entries;
|
|
38
61
|
for (let index = 0;index < length; index += 1) {
|
|
39
62
|
const entry = entries[index];
|
|
40
63
|
if (isArray) {
|
|
41
|
-
|
|
64
|
+
(callback ?? updateAttribute)(element, entry[1].name, entry[1].value);
|
|
42
65
|
} else {
|
|
43
|
-
|
|
66
|
+
(callback ?? updateAttribute)(element, entry[0], entry[1]);
|
|
44
67
|
}
|
|
45
68
|
}
|
|
46
69
|
}
|
|
@@ -74,6 +97,8 @@ var onPrefix = /^on/i;
|
|
|
74
97
|
var sourcePrefix = /^(href|src|xlink:href)$/i;
|
|
75
98
|
var valuePrefix = /(data:text\/html|javascript:)/i;
|
|
76
99
|
export {
|
|
100
|
+
setProperty,
|
|
101
|
+
setProperties,
|
|
77
102
|
setAttributes,
|
|
78
103
|
setAttribute,
|
|
79
104
|
isInvalidBooleanAttribute,
|
package/dist/event.js
CHANGED
|
@@ -7,6 +7,11 @@ function isPlainObject(value2) {
|
|
|
7
7
|
return (prototype === null || prototype === Object.prototype || Object.getPrototypeOf(prototype) === null) && !(Symbol.toStringTag in value2) && !(Symbol.iterator in value2);
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
+
// src/internal/get-value.ts
|
|
11
|
+
function getBoolean(value2, defaultValue) {
|
|
12
|
+
return typeof value2 === "boolean" ? value2 : defaultValue ?? false;
|
|
13
|
+
}
|
|
14
|
+
|
|
10
15
|
// src/event.ts
|
|
11
16
|
function createDispatchOptions(options) {
|
|
12
17
|
return {
|
|
@@ -26,25 +31,15 @@ function createEvent(type, options) {
|
|
|
26
31
|
return new Event(type, createDispatchOptions(hasOptions ? options : {}));
|
|
27
32
|
}
|
|
28
33
|
function createEventOptions(options) {
|
|
29
|
-
if (isPlainObject(options)) {
|
|
30
|
-
return {
|
|
31
|
-
capture: getBoolean(options.capture),
|
|
32
|
-
once: getBoolean(options.once),
|
|
33
|
-
passive: getBoolean(options.passive, true)
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
34
|
return {
|
|
37
|
-
capture: getBoolean(options),
|
|
38
|
-
once:
|
|
39
|
-
passive: true
|
|
35
|
+
capture: getBoolean(options?.capture),
|
|
36
|
+
once: getBoolean(options?.once),
|
|
37
|
+
passive: getBoolean(options?.passive, true)
|
|
40
38
|
};
|
|
41
39
|
}
|
|
42
40
|
function dispatch(target, type, options) {
|
|
43
41
|
target.dispatchEvent(createEvent(type, options));
|
|
44
42
|
}
|
|
45
|
-
function getBoolean(value2, defaultValue) {
|
|
46
|
-
return typeof value2 === "boolean" ? value2 : defaultValue ?? false;
|
|
47
|
-
}
|
|
48
43
|
function getPosition(event) {
|
|
49
44
|
let x;
|
|
50
45
|
let y;
|
package/dist/event.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// src/event.ts
|
|
2
2
|
import {isPlainObject} from "@oscarpalmer/atoms/is";
|
|
3
|
+
import {getBoolean} from "./internal/get-value";
|
|
3
4
|
function createDispatchOptions(options) {
|
|
4
5
|
return {
|
|
5
6
|
bubbles: getBoolean(options?.bubbles),
|
|
@@ -18,25 +19,15 @@ function createEvent(type, options) {
|
|
|
18
19
|
return new Event(type, createDispatchOptions(hasOptions ? options : {}));
|
|
19
20
|
}
|
|
20
21
|
function createEventOptions(options) {
|
|
21
|
-
if (isPlainObject(options)) {
|
|
22
|
-
return {
|
|
23
|
-
capture: getBoolean(options.capture),
|
|
24
|
-
once: getBoolean(options.once),
|
|
25
|
-
passive: getBoolean(options.passive, true)
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
22
|
return {
|
|
29
|
-
capture: getBoolean(options),
|
|
30
|
-
once:
|
|
31
|
-
passive: true
|
|
23
|
+
capture: getBoolean(options?.capture),
|
|
24
|
+
once: getBoolean(options?.once),
|
|
25
|
+
passive: getBoolean(options?.passive, true)
|
|
32
26
|
};
|
|
33
27
|
}
|
|
34
28
|
function dispatch(target, type, options) {
|
|
35
29
|
target.dispatchEvent(createEvent(type, options));
|
|
36
30
|
}
|
|
37
|
-
function getBoolean(value, defaultValue) {
|
|
38
|
-
return typeof value === "boolean" ? value : defaultValue ?? false;
|
|
39
|
-
}
|
|
40
31
|
function getPosition(event) {
|
|
41
32
|
let x;
|
|
42
33
|
let y;
|
package/dist/find.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/find.ts
|
|
2
|
-
function
|
|
2
|
+
function getDistanceBetweenElements(origin, target) {
|
|
3
3
|
if (origin === target || origin.parentElement === target) {
|
|
4
4
|
return 0;
|
|
5
5
|
}
|
|
@@ -86,7 +86,7 @@ function findRelatives(origin, selector, context) {
|
|
|
86
86
|
let minimum = null;
|
|
87
87
|
for (let index = 0;index < length; index += 1) {
|
|
88
88
|
const element = elements[index];
|
|
89
|
-
const distance =
|
|
89
|
+
const distance = getDistanceBetweenElements(origin, element);
|
|
90
90
|
if (distance < 0) {
|
|
91
91
|
continue;
|
|
92
92
|
}
|
|
@@ -144,6 +144,7 @@ function traverse(from, to) {
|
|
|
144
144
|
}
|
|
145
145
|
export {
|
|
146
146
|
getElementUnderPointer,
|
|
147
|
+
getDistanceBetweenElements,
|
|
147
148
|
findRelatives,
|
|
148
149
|
findElements,
|
|
149
150
|
findElement,
|
package/dist/find.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/find.ts
|
|
2
|
-
function
|
|
2
|
+
function getDistanceBetweenElements(origin, target) {
|
|
3
3
|
if (origin === target || origin.parentElement === target) {
|
|
4
4
|
return 0;
|
|
5
5
|
}
|
|
@@ -86,7 +86,7 @@ function findRelatives(origin, selector, context) {
|
|
|
86
86
|
let minimum = null;
|
|
87
87
|
for (let index = 0;index < length; index += 1) {
|
|
88
88
|
const element = elements[index];
|
|
89
|
-
const distance =
|
|
89
|
+
const distance = getDistanceBetweenElements(origin, element);
|
|
90
90
|
if (distance < 0) {
|
|
91
91
|
continue;
|
|
92
92
|
}
|
|
@@ -144,6 +144,7 @@ function traverse(from, to) {
|
|
|
144
144
|
}
|
|
145
145
|
export {
|
|
146
146
|
getElementUnderPointer,
|
|
147
|
+
getDistanceBetweenElements,
|
|
147
148
|
findRelatives,
|
|
148
149
|
findElements,
|
|
149
150
|
findElement,
|
package/dist/focusable.js
CHANGED
|
@@ -54,7 +54,7 @@ function isDisabled(item) {
|
|
|
54
54
|
if (/^(button|input|select|textarea)$/i.test(item.element.tagName) && isDisabledFromFieldset(item.element)) {
|
|
55
55
|
return true;
|
|
56
56
|
}
|
|
57
|
-
return
|
|
57
|
+
return item.element.disabled ?? false;
|
|
58
58
|
}
|
|
59
59
|
function isDisabledFromFieldset(element) {
|
|
60
60
|
let parent = element.parentElement;
|
package/dist/focusable.mjs
CHANGED
|
@@ -54,7 +54,7 @@ function isDisabled(item) {
|
|
|
54
54
|
if (/^(button|input|select|textarea)$/i.test(item.element.tagName) && isDisabledFromFieldset(item.element)) {
|
|
55
55
|
return true;
|
|
56
56
|
}
|
|
57
|
-
return
|
|
57
|
+
return item.element.disabled ?? false;
|
|
58
58
|
}
|
|
59
59
|
function isDisabledFromFieldset(element) {
|
|
60
60
|
let parent = element.parentElement;
|
package/dist/index.js
CHANGED
|
@@ -46,29 +46,52 @@ function isInvalidBooleanAttribute(attribute) {
|
|
|
46
46
|
return !(normalised.length === 0 || normalised === attribute.name || attribute.name === "hidden" && normalised === "until-found");
|
|
47
47
|
}
|
|
48
48
|
function setAttribute(element, first, second) {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
49
|
+
updateValue(element, first, second, updateAttribute);
|
|
50
|
+
}
|
|
51
|
+
function setAttributes(element, attributes) {
|
|
52
|
+
updateValues(element, attributes);
|
|
53
|
+
}
|
|
54
|
+
function setProperty(element, first, second) {
|
|
55
|
+
updateValue(element, first, second, updateProperty);
|
|
56
|
+
}
|
|
57
|
+
function setProperties(element, properties) {
|
|
58
|
+
updateValues(element, properties, updateProperty);
|
|
54
59
|
}
|
|
55
|
-
function
|
|
56
|
-
|
|
60
|
+
function updateAttribute(element, name, value2) {
|
|
61
|
+
const normalised = name.toLowerCase();
|
|
62
|
+
if (booleanAttributes.includes(normalised)) {
|
|
63
|
+
updateProperty(element, name, value2, false);
|
|
64
|
+
} else if (value2 == null) {
|
|
57
65
|
element.removeAttribute(name);
|
|
58
66
|
} else {
|
|
59
67
|
element.setAttribute(name, typeof value2 === "string" ? value2 : getString(value2));
|
|
60
68
|
}
|
|
61
69
|
}
|
|
62
|
-
function
|
|
63
|
-
const
|
|
64
|
-
|
|
70
|
+
function updateProperty(element, name, value2, validate) {
|
|
71
|
+
const actual = validate ?? true ? name.toLowerCase() : name;
|
|
72
|
+
if (actual === "hidden") {
|
|
73
|
+
element.hidden = typeof value2 === "string" && value2.toLowerCase() === "until-found" ? "until-found" : value2 === "" || value2 === true;
|
|
74
|
+
} else {
|
|
75
|
+
element[actual] = value2 === "" || typeof value2 === "string" && value2.toLowerCase() === actual || value2 === true;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
function updateValue(element, first, second, callback) {
|
|
79
|
+
if (isPlainObject(first) && typeof first?.name === "string") {
|
|
80
|
+
callback(element, first.name, first.value);
|
|
81
|
+
} else if (typeof first === "string") {
|
|
82
|
+
callback(element, first, second);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
function updateValues(element, values, callback) {
|
|
86
|
+
const isArray = Array.isArray(values);
|
|
87
|
+
const entries = Object.entries(values);
|
|
65
88
|
const { length } = entries;
|
|
66
89
|
for (let index = 0;index < length; index += 1) {
|
|
67
90
|
const entry = entries[index];
|
|
68
91
|
if (isArray) {
|
|
69
|
-
|
|
92
|
+
(callback ?? updateAttribute)(element, entry[1].name, entry[1].value);
|
|
70
93
|
} else {
|
|
71
|
-
|
|
94
|
+
(callback ?? updateAttribute)(element, entry[0], entry[1]);
|
|
72
95
|
}
|
|
73
96
|
}
|
|
74
97
|
}
|
|
@@ -147,6 +170,11 @@ function setData(element, first, second) {
|
|
|
147
170
|
function updateDataAttribute(element, key, value2) {
|
|
148
171
|
updateElementValue(element, `data-${key}`, value2, element.setAttribute, element.removeAttribute, true);
|
|
149
172
|
}
|
|
173
|
+
// src/internal/get-value.ts
|
|
174
|
+
function getBoolean(value2, defaultValue) {
|
|
175
|
+
return typeof value2 === "boolean" ? value2 : defaultValue ?? false;
|
|
176
|
+
}
|
|
177
|
+
|
|
150
178
|
// src/event.ts
|
|
151
179
|
function createDispatchOptions(options) {
|
|
152
180
|
return {
|
|
@@ -166,25 +194,15 @@ function createEvent(type, options) {
|
|
|
166
194
|
return new Event(type, createDispatchOptions(hasOptions ? options : {}));
|
|
167
195
|
}
|
|
168
196
|
function createEventOptions(options) {
|
|
169
|
-
if (isPlainObject(options)) {
|
|
170
|
-
return {
|
|
171
|
-
capture: getBoolean(options.capture),
|
|
172
|
-
once: getBoolean(options.once),
|
|
173
|
-
passive: getBoolean(options.passive, true)
|
|
174
|
-
};
|
|
175
|
-
}
|
|
176
197
|
return {
|
|
177
|
-
capture: getBoolean(options),
|
|
178
|
-
once:
|
|
179
|
-
passive: true
|
|
198
|
+
capture: getBoolean(options?.capture),
|
|
199
|
+
once: getBoolean(options?.once),
|
|
200
|
+
passive: getBoolean(options?.passive, true)
|
|
180
201
|
};
|
|
181
202
|
}
|
|
182
203
|
function dispatch(target, type, options) {
|
|
183
204
|
target.dispatchEvent(createEvent(type, options));
|
|
184
205
|
}
|
|
185
|
-
function getBoolean(value2, defaultValue) {
|
|
186
|
-
return typeof value2 === "boolean" ? value2 : defaultValue ?? false;
|
|
187
|
-
}
|
|
188
206
|
function getPosition(event) {
|
|
189
207
|
let x;
|
|
190
208
|
let y;
|
|
@@ -208,7 +226,7 @@ function on(target, type, listener, options) {
|
|
|
208
226
|
};
|
|
209
227
|
}
|
|
210
228
|
// src/find.ts
|
|
211
|
-
function
|
|
229
|
+
function getDistanceBetweenElements(origin, target) {
|
|
212
230
|
if (origin === target || origin.parentElement === target) {
|
|
213
231
|
return 0;
|
|
214
232
|
}
|
|
@@ -295,7 +313,7 @@ function findRelatives(origin, selector, context) {
|
|
|
295
313
|
let minimum = null;
|
|
296
314
|
for (let index = 0;index < length; index += 1) {
|
|
297
315
|
const element = elements[index];
|
|
298
|
-
const distance =
|
|
316
|
+
const distance = getDistanceBetweenElements(origin, element);
|
|
299
317
|
if (distance < 0) {
|
|
300
318
|
continue;
|
|
301
319
|
}
|
|
@@ -407,7 +425,7 @@ function isDisabled(item) {
|
|
|
407
425
|
if (/^(button|input|select|textarea)$/i.test(item.element.tagName) && isDisabledFromFieldset(item.element)) {
|
|
408
426
|
return true;
|
|
409
427
|
}
|
|
410
|
-
return
|
|
428
|
+
return item.element.disabled ?? false;
|
|
411
429
|
}
|
|
412
430
|
function isDisabledFromFieldset(element) {
|
|
413
431
|
let parent = element.parentElement;
|
|
@@ -562,6 +580,16 @@ function html(value2, sanitisation) {
|
|
|
562
580
|
return options != null ? sanitise([...cloned.childNodes], options) : [...cloned.childNodes];
|
|
563
581
|
}
|
|
564
582
|
var templates = {};
|
|
583
|
+
// src/is.ts
|
|
584
|
+
function isChildNode(value2, ignoreDocumentType) {
|
|
585
|
+
return value2 instanceof CharacterData || (value2 instanceof DocumentType ? ignoreDocumentType !== true : false) || value2 instanceof Element;
|
|
586
|
+
}
|
|
587
|
+
function isHTMLOrSVGElement(value2) {
|
|
588
|
+
return value2 instanceof HTMLElement || value2 instanceof SVGElement;
|
|
589
|
+
}
|
|
590
|
+
function isInDocument(node, document2) {
|
|
591
|
+
return document2 == null ? node.ownerDocument?.contains(node) ?? false : node.ownerDocument === document2 && document2.contains(node);
|
|
592
|
+
}
|
|
565
593
|
// src/style.ts
|
|
566
594
|
function getStyle(element, property) {
|
|
567
595
|
return element.style[property];
|
|
@@ -598,6 +626,8 @@ function updateStyleProperty(element, key, value2) {
|
|
|
598
626
|
export {
|
|
599
627
|
setStyles,
|
|
600
628
|
setStyle,
|
|
629
|
+
setProperty,
|
|
630
|
+
setProperties,
|
|
601
631
|
setData,
|
|
602
632
|
setAttributes,
|
|
603
633
|
setAttribute,
|
|
@@ -606,8 +636,11 @@ export {
|
|
|
606
636
|
off,
|
|
607
637
|
isTabbable,
|
|
608
638
|
isInvalidBooleanAttribute,
|
|
639
|
+
isInDocument,
|
|
640
|
+
isHTMLOrSVGElement,
|
|
609
641
|
isFocusable,
|
|
610
642
|
isEmptyNonBooleanAttribute,
|
|
643
|
+
isChildNode,
|
|
611
644
|
isBooleanAttribute,
|
|
612
645
|
isBadAttribute,
|
|
613
646
|
html,
|
|
@@ -618,6 +651,7 @@ export {
|
|
|
618
651
|
getPosition,
|
|
619
652
|
getFocusable,
|
|
620
653
|
getElementUnderPointer,
|
|
654
|
+
getDistanceBetweenElements,
|
|
621
655
|
getData,
|
|
622
656
|
findRelatives,
|
|
623
657
|
findElements,
|
package/dist/index.mjs
CHANGED
package/dist/is.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// src/is.ts
|
|
2
|
+
function isChildNode(value, ignoreDocumentType) {
|
|
3
|
+
return value instanceof CharacterData || (value instanceof DocumentType ? ignoreDocumentType !== true : false) || value instanceof Element;
|
|
4
|
+
}
|
|
5
|
+
function isHTMLOrSVGElement(value) {
|
|
6
|
+
return value instanceof HTMLElement || value instanceof SVGElement;
|
|
7
|
+
}
|
|
8
|
+
function isInDocument(node, document) {
|
|
9
|
+
return document == null ? node.ownerDocument?.contains(node) ?? false : node.ownerDocument === document && document.contains(node);
|
|
10
|
+
}
|
|
11
|
+
export {
|
|
12
|
+
isInDocument,
|
|
13
|
+
isHTMLOrSVGElement,
|
|
14
|
+
isChildNode
|
|
15
|
+
};
|
package/dist/is.mjs
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// src/is.ts
|
|
2
|
+
function isChildNode(value, ignoreDocumentType) {
|
|
3
|
+
return value instanceof CharacterData || (value instanceof DocumentType ? ignoreDocumentType !== true : false) || value instanceof Element;
|
|
4
|
+
}
|
|
5
|
+
function isHTMLOrSVGElement(value) {
|
|
6
|
+
return value instanceof HTMLElement || value instanceof SVGElement;
|
|
7
|
+
}
|
|
8
|
+
function isInDocument(node, document) {
|
|
9
|
+
return document == null ? node.ownerDocument?.contains(node) ?? false : node.ownerDocument === document && document.contains(node);
|
|
10
|
+
}
|
|
11
|
+
export {
|
|
12
|
+
isInDocument,
|
|
13
|
+
isHTMLOrSVGElement,
|
|
14
|
+
isChildNode
|
|
15
|
+
};
|
package/package.json
CHANGED
|
@@ -8,12 +8,13 @@
|
|
|
8
8
|
},
|
|
9
9
|
"description": "A collection of badass DOM utilities.",
|
|
10
10
|
"devDependencies": {
|
|
11
|
-
"@biomejs/biome": "^1.
|
|
12
|
-
"@happy-dom/global-registrator": "^
|
|
13
|
-
"@types/bun": "^1.1.
|
|
14
|
-
"bun": "^1.1.
|
|
11
|
+
"@biomejs/biome": "^1.9.0",
|
|
12
|
+
"@happy-dom/global-registrator": "^15.7.4",
|
|
13
|
+
"@types/bun": "^1.1.9",
|
|
14
|
+
"bun": "^1.1.27",
|
|
15
15
|
"dts-bundle-generator": "^9.5.1",
|
|
16
|
-
"
|
|
16
|
+
"type-fest": "^4.26.1",
|
|
17
|
+
"typescript": "^5.6.2"
|
|
17
18
|
},
|
|
18
19
|
"exports": {
|
|
19
20
|
".": {
|
|
@@ -63,6 +64,12 @@
|
|
|
63
64
|
"import": "./dist/html.mjs",
|
|
64
65
|
"require": "./dist/html.js"
|
|
65
66
|
},
|
|
67
|
+
"./is": {
|
|
68
|
+
"types": "./types/is.d.ts",
|
|
69
|
+
"bun": "./src/is.ts",
|
|
70
|
+
"import": "./dist/is.mjs",
|
|
71
|
+
"require": "./dist/is.js"
|
|
72
|
+
},
|
|
66
73
|
"./models": {
|
|
67
74
|
"types": "./types/models.d.ts",
|
|
68
75
|
"bun": "./src/models.ts"
|
|
@@ -80,15 +87,8 @@
|
|
|
80
87
|
"require": "./dist/style.js"
|
|
81
88
|
}
|
|
82
89
|
},
|
|
83
|
-
"files": [
|
|
84
|
-
|
|
85
|
-
"src",
|
|
86
|
-
"types"
|
|
87
|
-
],
|
|
88
|
-
"keywords": [
|
|
89
|
-
"dom",
|
|
90
|
-
"utility"
|
|
91
|
-
],
|
|
90
|
+
"files": ["dist", "src", "types"],
|
|
91
|
+
"keywords": ["dom", "utility"],
|
|
92
92
|
"license": "MIT",
|
|
93
93
|
"main": "dist/index.js",
|
|
94
94
|
"module": "dist/index.mjs",
|
|
@@ -109,5 +109,5 @@
|
|
|
109
109
|
},
|
|
110
110
|
"type": "module",
|
|
111
111
|
"types": "types/index.d.cts",
|
|
112
|
-
"version": "0.
|
|
112
|
+
"version": "0.13.0"
|
|
113
113
|
}
|