@oscarpalmer/toretto 0.45.0 → 0.47.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/aria.d.mts +68 -0
- package/dist/aria.mjs +49 -0
- package/dist/attribute/get.attribute.d.mts +3 -0
- package/dist/attribute/get.attribute.mjs +3 -3
- package/dist/attribute/index.d.mts +7 -1
- package/dist/attribute/set.attribute.d.mts +5 -0
- package/dist/attribute/set.attribute.mjs +1 -1
- package/dist/create.d.mts +4 -2
- package/dist/create.mjs +1 -1
- package/dist/data.d.mts +4 -0
- package/dist/data.mjs +1 -2
- package/dist/event/delegation.mjs +3 -4
- package/dist/event/index.d.mts +9 -1
- package/dist/event/index.mjs +3 -2
- package/dist/find/index.d.mts +14 -1
- package/dist/find/index.mjs +36 -1
- package/dist/find/relative.d.mts +5 -0
- package/dist/find/relative.mjs +1 -0
- package/dist/focusable.d.mts +4 -0
- package/dist/focusable.mjs +4 -0
- package/dist/html/index.d.mts +8 -4
- package/dist/html/index.mjs +4 -3
- package/dist/index.d.mts +185 -22
- package/dist/index.mjs +295 -144
- package/dist/internal/attribute.mjs +2 -2
- package/dist/internal/element-value.mjs +2 -4
- package/dist/internal/is.d.mts +15 -3
- package/dist/internal/is.mjs +15 -3
- package/dist/is.d.mts +5 -2
- package/dist/is.mjs +4 -3
- package/dist/models.d.mts +21 -8
- package/dist/property/get.property.d.mts +2 -0
- package/dist/property/get.property.mjs +4 -3
- package/dist/property/set.property.d.mts +3 -0
- package/dist/property/set.property.mjs +3 -4
- package/dist/style.d.mts +7 -0
- package/dist/style.mjs +8 -4
- package/dist/touch.d.mts +4 -0
- package/package.json +10 -6
- package/src/aria.ts +166 -0
- package/src/attribute/get.attribute.ts +5 -3
- package/src/attribute/index.ts +6 -0
- package/src/attribute/set.attribute.ts +5 -0
- package/src/create.ts +5 -3
- package/src/data.ts +11 -6
- package/src/event/delegation.ts +5 -6
- package/src/event/index.ts +11 -8
- package/src/find/index.ts +64 -1
- package/src/find/relative.ts +5 -0
- package/src/focusable.ts +4 -0
- package/src/html/index.ts +11 -9
- package/src/index.ts +1 -0
- package/src/internal/attribute.ts +4 -2
- package/src/internal/element-value.ts +2 -3
- package/src/internal/is.ts +22 -2
- package/src/is.ts +4 -1
- package/src/models.ts +122 -8
- package/src/property/get.property.ts +6 -5
- package/src/property/set.property.ts +5 -3
- package/src/style.ts +12 -6
- package/src/touch.ts +4 -0
package/dist/index.mjs
CHANGED
|
@@ -33,6 +33,7 @@ const supportsTouch = (() => {
|
|
|
33
33
|
//#region node_modules/@oscarpalmer/atoms/dist/internal/is.mjs
|
|
34
34
|
/**
|
|
35
35
|
* Is the value a number?
|
|
36
|
+
*
|
|
36
37
|
* @param value Value to check
|
|
37
38
|
* @returns `true` if the value is a `number`, otherwise `false`
|
|
38
39
|
*/
|
|
@@ -41,6 +42,7 @@ function isNumber(value) {
|
|
|
41
42
|
}
|
|
42
43
|
/**
|
|
43
44
|
* Is the value a plain object?
|
|
45
|
+
*
|
|
44
46
|
* @param value Value to check
|
|
45
47
|
* @returns `true` if the value is a plain object, otherwise `false`
|
|
46
48
|
*/
|
|
@@ -54,8 +56,20 @@ function isPlainObject(value) {
|
|
|
54
56
|
//#region node_modules/@oscarpalmer/atoms/dist/internal/string.mjs
|
|
55
57
|
/**
|
|
56
58
|
* Get the string value from any value
|
|
59
|
+
*
|
|
57
60
|
* @param value Original value
|
|
58
61
|
* @returns String representation of the value
|
|
62
|
+
*
|
|
63
|
+
* @example
|
|
64
|
+
* ```typescript
|
|
65
|
+
* getString(null) // => ''
|
|
66
|
+
* getString('foo') // => 'foo'
|
|
67
|
+
* getString(123) // => '123'
|
|
68
|
+
* getString(true) // => 'true'
|
|
69
|
+
* getString([1, 2, 3]) // => '1,2,3'
|
|
70
|
+
* getString({a: 1}) // => '{"a":1}'
|
|
71
|
+
* getString(() => 123) // => '123'
|
|
72
|
+
* ```
|
|
59
73
|
*/
|
|
60
74
|
function getString(value) {
|
|
61
75
|
if (typeof value === "string") return value;
|
|
@@ -69,6 +83,7 @@ function getString(value) {
|
|
|
69
83
|
* Join an array of values into a string _(while ignoring empty values)_
|
|
70
84
|
*
|
|
71
85
|
* _(`null`, `undefined`, and any values that become whitespace-only strings are considered empty)_
|
|
86
|
+
*
|
|
72
87
|
* @param array Array of values
|
|
73
88
|
* @param delimiter Delimiter to use between values
|
|
74
89
|
* @returns Joined string
|
|
@@ -80,12 +95,13 @@ function join(array, delimiter) {
|
|
|
80
95
|
const values = [];
|
|
81
96
|
for (let index = 0; index < length; index += 1) {
|
|
82
97
|
const item = getString(array[index]);
|
|
83
|
-
if (item.
|
|
98
|
+
if (item.length > 0) values.push(item);
|
|
84
99
|
}
|
|
85
100
|
return values.join(typeof delimiter === "string" ? delimiter : "");
|
|
86
101
|
}
|
|
87
102
|
/**
|
|
88
103
|
* Split a string into words _(and other readable parts)_
|
|
104
|
+
*
|
|
89
105
|
* @param value Original string
|
|
90
106
|
* @returns Array of words found in the string
|
|
91
107
|
*/
|
|
@@ -97,6 +113,7 @@ const EXPRESSION_WORDS = /[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;
|
|
|
97
113
|
//#region node_modules/@oscarpalmer/atoms/dist/is.mjs
|
|
98
114
|
/**
|
|
99
115
|
* Is the value `undefined`, `null`, or stringified as a whitespace-only string?
|
|
116
|
+
*
|
|
100
117
|
* @param value Value to check
|
|
101
118
|
* @returns `true` if the value is nullable or matches a whitespace-only string, otherwise `false`
|
|
102
119
|
*/
|
|
@@ -108,6 +125,7 @@ const EXPRESSION_WHITESPACE$1 = /^\s*$/;
|
|
|
108
125
|
//#region node_modules/@oscarpalmer/atoms/dist/string/index.mjs
|
|
109
126
|
/**
|
|
110
127
|
* Parse a JSON string into its proper value _(or `undefined` if it fails)_
|
|
128
|
+
*
|
|
111
129
|
* @param value JSON string to parse
|
|
112
130
|
* @param reviver Reviver function to transform the parsed values
|
|
113
131
|
* @returns Parsed value or `undefined` if parsing fails
|
|
@@ -123,11 +141,18 @@ function parse(value, reviver) {
|
|
|
123
141
|
//#region node_modules/@oscarpalmer/atoms/dist/internal/number.mjs
|
|
124
142
|
/**
|
|
125
143
|
* Clamp a number between a minimum and maximum value
|
|
144
|
+
*
|
|
126
145
|
* @param value Value to clamp
|
|
127
146
|
* @param minimum Minimum value
|
|
128
147
|
* @param maximum Maximum value
|
|
129
148
|
* @param loop If `true`, the value will loop around when smaller than the minimum or larger than the maximum _(defaults to `false`)_
|
|
130
149
|
* @returns Clamped value
|
|
150
|
+
*
|
|
151
|
+
* @example
|
|
152
|
+
* ```typescript
|
|
153
|
+
* clamp(10, 0, 5); // => 5
|
|
154
|
+
* clamp(10, 0, 5, true); // => 0
|
|
155
|
+
* ```
|
|
131
156
|
*/
|
|
132
157
|
function clamp(value, minimum, maximum, loop) {
|
|
133
158
|
if (![
|
|
@@ -151,17 +176,17 @@ const MAXIMUM_DEFAULT = 1048576;
|
|
|
151
176
|
//#endregion
|
|
152
177
|
//#region node_modules/@oscarpalmer/atoms/dist/sized/map.mjs
|
|
153
178
|
/**
|
|
154
|
-
* A
|
|
179
|
+
* A _Map_ with a maximum size
|
|
155
180
|
*
|
|
156
|
-
* Behavior is similar to a _LRU_
|
|
181
|
+
* Behavior is similar to a _LRU_ cache, where the least recently used entries are removed
|
|
157
182
|
*/
|
|
158
183
|
var SizedMap = class extends Map {
|
|
159
184
|
/**
|
|
160
|
-
* The maximum size of the
|
|
185
|
+
* The maximum size of the _Map_
|
|
161
186
|
*/
|
|
162
187
|
#maximumSize;
|
|
163
188
|
/**
|
|
164
|
-
* Is the
|
|
189
|
+
* Is the _Map_ full?
|
|
165
190
|
*/
|
|
166
191
|
get full() {
|
|
167
192
|
return super.size >= this.#maximumSize;
|
|
@@ -205,18 +230,22 @@ var SizedMap = class extends Map {
|
|
|
205
230
|
//#endregion
|
|
206
231
|
//#region node_modules/@oscarpalmer/atoms/dist/function/memoize.mjs
|
|
207
232
|
/**
|
|
208
|
-
* A
|
|
233
|
+
* A _Memoized_ function instance, caching and retrieving results based on the its parameters _(or a custom cache key)_
|
|
209
234
|
*/
|
|
210
235
|
var Memoized = class {
|
|
211
236
|
#state;
|
|
212
237
|
/**
|
|
213
238
|
* Maximum cache size
|
|
239
|
+
*
|
|
240
|
+
* @returns Maximum cache size _(or `Number.NaN` if the instance has been destroyed)_
|
|
214
241
|
*/
|
|
215
242
|
get maximum() {
|
|
216
243
|
return this.#state.cache?.maximum ?? NaN;
|
|
217
244
|
}
|
|
218
245
|
/**
|
|
219
246
|
* Current cache size
|
|
247
|
+
*
|
|
248
|
+
* @returns Current cache size _(or `Number.NaN` if the instance has been destroyed)_
|
|
220
249
|
*/
|
|
221
250
|
get size() {
|
|
222
251
|
return this.#state.cache?.size ?? NaN;
|
|
@@ -243,6 +272,7 @@ var Memoized = class {
|
|
|
243
272
|
}
|
|
244
273
|
/**
|
|
245
274
|
* Delete a result from the cache
|
|
275
|
+
*
|
|
246
276
|
* @param key Key to delete
|
|
247
277
|
* @returns `true` if the key existed and was removed, otherwise `false`
|
|
248
278
|
*/
|
|
@@ -250,7 +280,9 @@ var Memoized = class {
|
|
|
250
280
|
return this.#state.cache?.delete(key) ?? false;
|
|
251
281
|
}
|
|
252
282
|
/**
|
|
253
|
-
* Destroy the instance
|
|
283
|
+
* Destroy the instance
|
|
284
|
+
*
|
|
285
|
+
* _(When a Memoized instance is destroyed, its cache and callback are removed, and calls to `run` will throw an error)_
|
|
254
286
|
*/
|
|
255
287
|
destroy() {
|
|
256
288
|
this.#state.cache?.clear();
|
|
@@ -259,6 +291,7 @@ var Memoized = class {
|
|
|
259
291
|
}
|
|
260
292
|
/**
|
|
261
293
|
* Get a result from the cache
|
|
294
|
+
*
|
|
262
295
|
* @param key Key to get
|
|
263
296
|
* @returns Cached result or `undefined` if it does not exist
|
|
264
297
|
*/
|
|
@@ -267,6 +300,7 @@ var Memoized = class {
|
|
|
267
300
|
}
|
|
268
301
|
/**
|
|
269
302
|
* Does the result exist?
|
|
303
|
+
*
|
|
270
304
|
* @param key Key to check
|
|
271
305
|
* @returns `true` if the result exists, otherwise `false`
|
|
272
306
|
*/
|
|
@@ -275,11 +309,12 @@ var Memoized = class {
|
|
|
275
309
|
}
|
|
276
310
|
/**
|
|
277
311
|
* Run the callback with the provided parameters
|
|
312
|
+
*
|
|
278
313
|
* @param parameters Parameters to pass to the callback
|
|
279
314
|
* @returns Cached or computed _(then cached)_ result
|
|
280
315
|
*/
|
|
281
316
|
run(...parameters) {
|
|
282
|
-
if (this.#state.cache == null || this.#state.getter == null) throw new Error(
|
|
317
|
+
if (this.#state.cache == null || this.#state.getter == null) throw new Error(MEMOIZED_ERROR_DESTROYED);
|
|
283
318
|
return this.#state.getter(...parameters);
|
|
284
319
|
}
|
|
285
320
|
};
|
|
@@ -292,19 +327,24 @@ function getMemoizationOptions(input) {
|
|
|
292
327
|
}
|
|
293
328
|
/**
|
|
294
329
|
* Memoize a function, caching and retrieving results based on the first parameter
|
|
330
|
+
*
|
|
295
331
|
* @param callback Callback to memoize
|
|
296
332
|
* @param options Memoization options
|
|
297
|
-
* @returns
|
|
333
|
+
* @returns _Memoized_ instance
|
|
298
334
|
*/
|
|
299
335
|
function memoize(callback, options) {
|
|
336
|
+
if (typeof callback !== "function") throw new TypeError(MEMOIZED_ERROR_CALLBACK);
|
|
300
337
|
return new Memoized(callback, getMemoizationOptions(options));
|
|
301
338
|
}
|
|
302
339
|
const DEFAULT_CACHE_SIZE = 1024;
|
|
340
|
+
const MEMOIZED_ERROR_CALLBACK = "Memoized requires a callback function";
|
|
341
|
+
const MEMOIZED_ERROR_DESTROYED = "The Memoized instance has been destroyed";
|
|
303
342
|
const SEPARATOR = "_";
|
|
304
343
|
//#endregion
|
|
305
344
|
//#region node_modules/@oscarpalmer/atoms/dist/string/case.mjs
|
|
306
345
|
/**
|
|
307
346
|
* Convert a string to camel case _(thisIsCamelCase)_
|
|
347
|
+
*
|
|
308
348
|
* @param value String to convert
|
|
309
349
|
* @returns Camel-cased string
|
|
310
350
|
*/
|
|
@@ -313,6 +353,7 @@ function camelCase(value) {
|
|
|
313
353
|
}
|
|
314
354
|
/**
|
|
315
355
|
* Capitalize the first letter of a string _(and lowercase the rest)_
|
|
356
|
+
*
|
|
316
357
|
* @param value String to capitalize
|
|
317
358
|
* @returns Capitalized string
|
|
318
359
|
*/
|
|
@@ -323,6 +364,7 @@ function capitalize(value) {
|
|
|
323
364
|
}
|
|
324
365
|
/**
|
|
325
366
|
* Convert a string to kebab case _(this-is-kebab-case)_
|
|
367
|
+
*
|
|
326
368
|
* @param value String to convert
|
|
327
369
|
* @returns Kebab-cased string
|
|
328
370
|
*/
|
|
@@ -382,7 +424,17 @@ let memoizedCapitalize;
|
|
|
382
424
|
//#endregion
|
|
383
425
|
//#region src/internal/is.ts
|
|
384
426
|
/**
|
|
427
|
+
* Is the value an event position?
|
|
428
|
+
*
|
|
429
|
+
* @param value Value to check
|
|
430
|
+
* @returns `true` if it's an event position, otherwise `false`
|
|
431
|
+
*/
|
|
432
|
+
function isEventPosition(value) {
|
|
433
|
+
return typeof value === "object" && value != null && typeof value.x === "number" && typeof value.y === "number";
|
|
434
|
+
}
|
|
435
|
+
/**
|
|
385
436
|
* Is the value an event target?
|
|
437
|
+
*
|
|
386
438
|
* @param value Value to check
|
|
387
439
|
* @returns `true` if it's an event target, otherwise `false`
|
|
388
440
|
*/
|
|
@@ -390,15 +442,17 @@ function isEventTarget(value) {
|
|
|
390
442
|
return typeof value === "object" && value != null && typeof value.addEventListener === "function" && typeof value.removeEventListener === "function" && typeof value.dispatchEvent === "function";
|
|
391
443
|
}
|
|
392
444
|
/**
|
|
393
|
-
* Is the value an
|
|
445
|
+
* Is the value an _HTML_ or _SVG_ element?
|
|
446
|
+
*
|
|
394
447
|
* @param value Value to check
|
|
395
|
-
* @returns `true` if it's an
|
|
448
|
+
* @returns `true` if it's an _HTML_ or _SVG_ element, otherwise `false`
|
|
396
449
|
*/
|
|
397
450
|
function isHTMLOrSVGElement(value) {
|
|
398
451
|
return value instanceof HTMLElement || value instanceof SVGElement;
|
|
399
452
|
}
|
|
400
453
|
/**
|
|
401
454
|
* Is the value an input element? _(`<input>`, `<select>`, or `<textarea>`)_
|
|
455
|
+
*
|
|
402
456
|
* @param value Value to check
|
|
403
457
|
* @returns `true` if it's an input element, otherwise `false`
|
|
404
458
|
*/
|
|
@@ -406,66 +460,6 @@ function isInputElement(value) {
|
|
|
406
460
|
return value instanceof HTMLInputElement || value instanceof HTMLSelectElement || value instanceof HTMLTextAreaElement;
|
|
407
461
|
}
|
|
408
462
|
//#endregion
|
|
409
|
-
//#region src/is.ts
|
|
410
|
-
/**
|
|
411
|
-
* Is the value a child node?
|
|
412
|
-
* @param value Value to check
|
|
413
|
-
* @returns `true` if it's a child node, otherwise `false`
|
|
414
|
-
*/
|
|
415
|
-
function isChildNode(value) {
|
|
416
|
-
return value instanceof Node && CHILD_NODE_TYPES.has(value.nodeType);
|
|
417
|
-
}
|
|
418
|
-
function isInDocument(node, doc) {
|
|
419
|
-
if (!(node instanceof Node)) return false;
|
|
420
|
-
if (!(doc instanceof Document)) return node.ownerDocument?.contains(node) ?? true;
|
|
421
|
-
return node.ownerDocument == null ? node === doc : node.ownerDocument === doc && doc.contains(node);
|
|
422
|
-
}
|
|
423
|
-
const CHILD_NODE_TYPES = new Set([
|
|
424
|
-
Node.ELEMENT_NODE,
|
|
425
|
-
Node.TEXT_NODE,
|
|
426
|
-
Node.PROCESSING_INSTRUCTION_NODE,
|
|
427
|
-
Node.COMMENT_NODE,
|
|
428
|
-
Node.DOCUMENT_TYPE_NODE
|
|
429
|
-
]);
|
|
430
|
-
//#endregion
|
|
431
|
-
//#region src/internal/element-value.ts
|
|
432
|
-
function ignoreSetAttribute(element, name) {
|
|
433
|
-
if (element instanceof HTMLTextAreaElement && name === "value") return true;
|
|
434
|
-
return false;
|
|
435
|
-
}
|
|
436
|
-
function normalizeKey(key, style) {
|
|
437
|
-
return style && key.startsWith(CSS_VARIABLE_PREFIX$1) ? key : kebabCase(key);
|
|
438
|
-
}
|
|
439
|
-
function setElementValue(element, first, second, third, callback, style) {
|
|
440
|
-
if (!isHTMLOrSVGElement(element)) return;
|
|
441
|
-
if (typeof first === "string") setElementValues(element, first, second, third, callback, style);
|
|
442
|
-
else if (isAttribute(first)) setElementValues(element, first.name, first.value, third, callback, style);
|
|
443
|
-
}
|
|
444
|
-
function setElementValues(element, first, second, third, callback, style) {
|
|
445
|
-
if (!isHTMLOrSVGElement(element)) return;
|
|
446
|
-
const dispatch = third !== false;
|
|
447
|
-
if (typeof first === "string") {
|
|
448
|
-
callback(element, normalizeKey(first, style), second, dispatch);
|
|
449
|
-
return;
|
|
450
|
-
}
|
|
451
|
-
const isArray = Array.isArray(first);
|
|
452
|
-
if (!isArray && !(typeof first === "object" && first !== null)) return;
|
|
453
|
-
const entries = isArray ? first : Object.entries(first).map(([name, value]) => ({
|
|
454
|
-
name,
|
|
455
|
-
value
|
|
456
|
-
}));
|
|
457
|
-
const { length } = entries;
|
|
458
|
-
for (let index = 0; index < length; index += 1) {
|
|
459
|
-
const entry = entries[index];
|
|
460
|
-
if (typeof entry === "object" && typeof entry?.name === "string") callback(element, normalizeKey(entry.name, style), entry.value, dispatch);
|
|
461
|
-
}
|
|
462
|
-
}
|
|
463
|
-
function updateElementValue(element, key, value, set, remove, isBoolean, json) {
|
|
464
|
-
if (isBoolean ? value == null : isNullableOrWhitespace(value)) remove.call(element, key);
|
|
465
|
-
else if (!ignoreSetAttribute(element, key)) set.call(element, key, json ? JSON.stringify(value) : getString(value));
|
|
466
|
-
}
|
|
467
|
-
const CSS_VARIABLE_PREFIX$1 = "--";
|
|
468
|
-
//#endregion
|
|
469
463
|
//#region src/internal/property.ts
|
|
470
464
|
function getPropertyValue$1(element, name, value) {
|
|
471
465
|
if (isInputElement(element) && name === "value") return getString(value);
|
|
@@ -586,7 +580,7 @@ const booleanAttributes = Object.freeze([
|
|
|
586
580
|
"selected"
|
|
587
581
|
]);
|
|
588
582
|
const booleanAttributesSet = new Set(booleanAttributes);
|
|
589
|
-
const dispatchedAttributes = new Set([
|
|
583
|
+
const dispatchedAttributes = /* @__PURE__ */ new Set([
|
|
590
584
|
"checked",
|
|
591
585
|
"open",
|
|
592
586
|
"value"
|
|
@@ -594,6 +588,91 @@ const dispatchedAttributes = new Set([
|
|
|
594
588
|
const formElement = document.createElement("form");
|
|
595
589
|
let textArea;
|
|
596
590
|
//#endregion
|
|
591
|
+
//#region src/internal/element-value.ts
|
|
592
|
+
function ignoreSetAttribute(element, name) {
|
|
593
|
+
if (element instanceof HTMLTextAreaElement && name === "value") return true;
|
|
594
|
+
return false;
|
|
595
|
+
}
|
|
596
|
+
function normalizeKey(key, style) {
|
|
597
|
+
return style && key.startsWith(CSS_VARIABLE_PREFIX$1) ? key : kebabCase(key);
|
|
598
|
+
}
|
|
599
|
+
function setElementValue(element, first, second, third, callback, style) {
|
|
600
|
+
if (!(element instanceof Element)) return;
|
|
601
|
+
if (typeof first === "string") setElementValues(element, first, second, third, callback, style);
|
|
602
|
+
else if (isAttribute(first)) setElementValues(element, first.name, first.value, third, callback, style);
|
|
603
|
+
}
|
|
604
|
+
function setElementValues(element, first, second, third, callback, style) {
|
|
605
|
+
if (!(element instanceof Element)) return;
|
|
606
|
+
const dispatch = third !== false;
|
|
607
|
+
if (typeof first === "string") {
|
|
608
|
+
callback(element, normalizeKey(first, style), second, dispatch);
|
|
609
|
+
return;
|
|
610
|
+
}
|
|
611
|
+
const isArray = Array.isArray(first);
|
|
612
|
+
if (!isArray && !(typeof first === "object" && first !== null)) return;
|
|
613
|
+
const entries = isArray ? first : Object.entries(first).map(([name, value]) => ({
|
|
614
|
+
name,
|
|
615
|
+
value
|
|
616
|
+
}));
|
|
617
|
+
const { length } = entries;
|
|
618
|
+
for (let index = 0; index < length; index += 1) {
|
|
619
|
+
const entry = entries[index];
|
|
620
|
+
if (typeof entry === "object" && typeof entry?.name === "string") callback(element, normalizeKey(entry.name, style), entry.value, dispatch);
|
|
621
|
+
}
|
|
622
|
+
}
|
|
623
|
+
function updateElementValue(element, key, value, set, remove, isBoolean, json) {
|
|
624
|
+
if (isBoolean ? value == null : isNullableOrWhitespace(value)) remove.call(element, key);
|
|
625
|
+
else if (!ignoreSetAttribute(element, key)) set.call(element, key, json ? JSON.stringify(value) : getString(value));
|
|
626
|
+
}
|
|
627
|
+
const CSS_VARIABLE_PREFIX$1 = "--";
|
|
628
|
+
//#endregion
|
|
629
|
+
//#region src/aria.ts
|
|
630
|
+
function getAria(element, value) {
|
|
631
|
+
if (!(element instanceof Element)) return Array.isArray(value) ? {} : void 0;
|
|
632
|
+
if (!Array.isArray(value)) return typeof value === "string" ? getAriaValue(element, value) : void 0;
|
|
633
|
+
const arias = {};
|
|
634
|
+
const { length } = value;
|
|
635
|
+
for (let index = 0; index < length; index += 1) {
|
|
636
|
+
const attribute = value[index];
|
|
637
|
+
if (typeof attribute === "string") arias[attribute.replace(ATTRIBUTE_ARIA_PREFIX, "")] = getAriaValue(element, attribute);
|
|
638
|
+
}
|
|
639
|
+
return arias;
|
|
640
|
+
}
|
|
641
|
+
function getAriaValue(element, attribute) {
|
|
642
|
+
return element.getAttribute(getName$1(attribute)) ?? void 0;
|
|
643
|
+
}
|
|
644
|
+
function getName$1(value) {
|
|
645
|
+
return EXPRESSION_ARIA_PREFIX.test(value) ? value : `${ATTRIBUTE_ARIA_PREFIX}${value}`;
|
|
646
|
+
}
|
|
647
|
+
/**
|
|
648
|
+
* Get the role of an element
|
|
649
|
+
*
|
|
650
|
+
* @param element Element to get role from
|
|
651
|
+
* @returns Element role _(or `undefined`)_
|
|
652
|
+
*/
|
|
653
|
+
function getRole(element) {
|
|
654
|
+
if (element instanceof Element) return element.getAttribute("role") ?? void 0;
|
|
655
|
+
}
|
|
656
|
+
function setAria(element, first, second) {
|
|
657
|
+
setElementValues(element, first, second, null, updateAriaAttribute);
|
|
658
|
+
}
|
|
659
|
+
/**
|
|
660
|
+
* Set the role of an element
|
|
661
|
+
*
|
|
662
|
+
* @param element Element for role
|
|
663
|
+
* @param role Role to set _(or `undefined` to remove it)_
|
|
664
|
+
*/
|
|
665
|
+
function setRole(element, role) {
|
|
666
|
+
if (!(element instanceof Element)) return;
|
|
667
|
+
if (typeof role === "string") element.setAttribute("role", role);
|
|
668
|
+
else element.removeAttribute("role");
|
|
669
|
+
}
|
|
670
|
+
function updateAriaAttribute(element, key, value) {
|
|
671
|
+
updateElementValue(element, getName$1(key), value, element.setAttribute, element.removeAttribute, false, false);
|
|
672
|
+
}
|
|
673
|
+
const ATTRIBUTE_ARIA_PREFIX = "aria-";
|
|
674
|
+
const EXPRESSION_ARIA_PREFIX = /^aria-/i;
|
|
675
|
+
//#endregion
|
|
597
676
|
//#region src/internal/get-value.ts
|
|
598
677
|
function getBoolean(value, defaultValue) {
|
|
599
678
|
return typeof value === "boolean" ? value : defaultValue ?? false;
|
|
@@ -614,10 +693,11 @@ const CSS_VARIABLE_PREFIX = "--";
|
|
|
614
693
|
//#endregion
|
|
615
694
|
//#region src/attribute/get.attribute.ts
|
|
616
695
|
function getAttribute(element, name, parseValues) {
|
|
617
|
-
if (
|
|
696
|
+
if (element instanceof Element && typeof name === "string") return getAttributeValue(element, kebabCase(name), parseValues !== false);
|
|
618
697
|
}
|
|
619
698
|
/**
|
|
620
699
|
* Get specific attributes from an element
|
|
700
|
+
*
|
|
621
701
|
* @param element Element to get attributes from
|
|
622
702
|
* @param names Attribute names
|
|
623
703
|
* @param parseData Parse data values? _(defaults to `true`)_
|
|
@@ -625,7 +705,7 @@ function getAttribute(element, name, parseValues) {
|
|
|
625
705
|
*/
|
|
626
706
|
function getAttributes(element, names, parseData) {
|
|
627
707
|
const attributes = {};
|
|
628
|
-
if (!(
|
|
708
|
+
if (!(element instanceof Element && Array.isArray(names))) return attributes;
|
|
629
709
|
const shouldParse = parseData !== false;
|
|
630
710
|
const { length } = names;
|
|
631
711
|
for (let index = 0; index < length; index += 1) {
|
|
@@ -654,19 +734,80 @@ function isInvalidBooleanAttribute(first, second) {
|
|
|
654
734
|
return _isInvalidBooleanAttribute(first, second, true);
|
|
655
735
|
}
|
|
656
736
|
//#endregion
|
|
737
|
+
//#region src/property/get.property.ts
|
|
738
|
+
/**
|
|
739
|
+
* Get the values of one or more properties on an element
|
|
740
|
+
*
|
|
741
|
+
* @param target Target element
|
|
742
|
+
* @param properties Properties to get
|
|
743
|
+
* @returns Property values
|
|
744
|
+
*/
|
|
745
|
+
function getProperties(target, properties) {
|
|
746
|
+
const values = {};
|
|
747
|
+
if (!(target instanceof Element && Array.isArray(properties))) return values;
|
|
748
|
+
const { length } = properties;
|
|
749
|
+
for (let index = 0; index < length; index += 1) {
|
|
750
|
+
const property = properties[index];
|
|
751
|
+
if (typeof property === "string") values[property] = getPropertyValue(target, property);
|
|
752
|
+
}
|
|
753
|
+
return values;
|
|
754
|
+
}
|
|
755
|
+
/**
|
|
756
|
+
* Get the value of a property on an element
|
|
757
|
+
*
|
|
758
|
+
* @param target Target element
|
|
759
|
+
* @param property Property to get
|
|
760
|
+
* @returns Property value
|
|
761
|
+
*/
|
|
762
|
+
function getProperty(target, property) {
|
|
763
|
+
if (target instanceof Element && typeof property === "string") return getPropertyValue(target, property);
|
|
764
|
+
}
|
|
765
|
+
function getPropertyValue(element, property) {
|
|
766
|
+
let actual = property;
|
|
767
|
+
if (!(actual in element)) actual = camelCase(actual);
|
|
768
|
+
if (actual in element) return element[actual];
|
|
769
|
+
}
|
|
770
|
+
//#endregion
|
|
771
|
+
//#region src/property/set.property.ts
|
|
772
|
+
/**
|
|
773
|
+
* Set the values of one or more properties on an element
|
|
774
|
+
*
|
|
775
|
+
* Also updates attributes for boolean/dispatchable properties, and if `dispatch` is `true`, will dispatch events for dispatchable properties
|
|
776
|
+
*
|
|
777
|
+
* @param target Target element
|
|
778
|
+
* @param properties Properties to set
|
|
779
|
+
* @param dispatch Dispatch events for properties? _(defaults to `true`)_
|
|
780
|
+
*/
|
|
781
|
+
function setProperties(target, properties, dispatch) {
|
|
782
|
+
if (!(target instanceof Element) || !isPlainObject(properties)) return;
|
|
783
|
+
const shouldDispatch = dispatch !== false;
|
|
784
|
+
const keys = Object.keys(properties);
|
|
785
|
+
const { length } = keys;
|
|
786
|
+
for (let index = 0; index < length; index += 1) setPropertyValue(target, keys[index], properties[keys[index]], shouldDispatch);
|
|
787
|
+
}
|
|
788
|
+
function setProperty(target, property, value, dispatch) {
|
|
789
|
+
if (target instanceof Element && typeof property === "string") setPropertyValue(target, property, value, dispatch !== false);
|
|
790
|
+
}
|
|
791
|
+
function setPropertyValue(element, property, value, dispatch) {
|
|
792
|
+
if (booleanAttributesSet.has(property.toLowerCase()) || dispatchedAttributes.has(property)) setAttribute(element, property, value, dispatch);
|
|
793
|
+
else updateProperty(element, property, value, dispatch);
|
|
794
|
+
}
|
|
795
|
+
//#endregion
|
|
657
796
|
//#region src/style.ts
|
|
658
797
|
/**
|
|
659
798
|
* Get a style from an element
|
|
799
|
+
*
|
|
660
800
|
* @param element Element to get the style from
|
|
661
801
|
* @param property Style name
|
|
662
802
|
* @param computed Get the computed style? _(defaults to `false`)_
|
|
663
803
|
* @returns Style value
|
|
664
804
|
*/
|
|
665
805
|
function getStyle(element, property, computed) {
|
|
666
|
-
if (
|
|
806
|
+
if (element instanceof Element && typeof property === "string") return getStyleValue(element, property, computed === true);
|
|
667
807
|
}
|
|
668
808
|
/**
|
|
669
809
|
* Get styles from an element
|
|
810
|
+
*
|
|
670
811
|
* @param element Element to get the styles from
|
|
671
812
|
* @param properties Styles to get
|
|
672
813
|
* @param computed Get the computed styles? _(defaults to `false`)_
|
|
@@ -674,7 +815,7 @@ function getStyle(element, property, computed) {
|
|
|
674
815
|
*/
|
|
675
816
|
function getStyles(element, properties, computed) {
|
|
676
817
|
const styles = {};
|
|
677
|
-
if (!(
|
|
818
|
+
if (!(element instanceof Element && Array.isArray(properties))) return styles;
|
|
678
819
|
const { length } = properties;
|
|
679
820
|
for (let index = 0; index < length; index += 1) {
|
|
680
821
|
const property = properties[index];
|
|
@@ -684,7 +825,7 @@ function getStyles(element, properties, computed) {
|
|
|
684
825
|
}
|
|
685
826
|
function getTextDirection(node) {
|
|
686
827
|
let target;
|
|
687
|
-
if (
|
|
828
|
+
if (node instanceof Element) target = node;
|
|
688
829
|
else target = node instanceof Node ? node.ownerDocument?.documentElement ?? document.documentElement : document.documentElement;
|
|
689
830
|
let { direction } = target.style;
|
|
690
831
|
if (direction === "") direction = getStyleValue(target, PROPERTY_DIRECTION, true);
|
|
@@ -692,6 +833,7 @@ function getTextDirection(node) {
|
|
|
692
833
|
}
|
|
693
834
|
/**
|
|
694
835
|
* Set a style on an element
|
|
836
|
+
*
|
|
695
837
|
* @param element Element to set the style on
|
|
696
838
|
* @param property Style name
|
|
697
839
|
* @param value Style value
|
|
@@ -701,6 +843,7 @@ function setStyle(element, property, value) {
|
|
|
701
843
|
}
|
|
702
844
|
/**
|
|
703
845
|
* Set styles on an element
|
|
846
|
+
*
|
|
704
847
|
* @param element Element to set the styles on
|
|
705
848
|
* @param styles Styles to set
|
|
706
849
|
*/
|
|
@@ -709,6 +852,7 @@ function setStyles(element, styles) {
|
|
|
709
852
|
}
|
|
710
853
|
/**
|
|
711
854
|
* Toggle styles for an element
|
|
855
|
+
*
|
|
712
856
|
* @param element Element to style
|
|
713
857
|
* @param styles Styles to be set or removed
|
|
714
858
|
* @returns Style toggler
|
|
@@ -756,62 +900,6 @@ const DIRECTION_RTL = "rtl";
|
|
|
756
900
|
const PROPERTY_DIRECTION = "direction";
|
|
757
901
|
const VARIABLE_PREFIX = "--";
|
|
758
902
|
//#endregion
|
|
759
|
-
//#region src/property/get.property.ts
|
|
760
|
-
/**
|
|
761
|
-
* Get the values of one or more properties on an element
|
|
762
|
-
* @param target Target element
|
|
763
|
-
* @param properties Properties to get
|
|
764
|
-
* @returns Property values
|
|
765
|
-
*/
|
|
766
|
-
function getProperties(target, properties) {
|
|
767
|
-
const values = {};
|
|
768
|
-
if (!isHTMLOrSVGElement(target) || !Array.isArray(properties)) return values;
|
|
769
|
-
const { length } = properties;
|
|
770
|
-
for (let index = 0; index < length; index += 1) {
|
|
771
|
-
const property = properties[index];
|
|
772
|
-
if (typeof property === "string") values[property] = getPropertyValue(target, property);
|
|
773
|
-
}
|
|
774
|
-
return values;
|
|
775
|
-
}
|
|
776
|
-
/**
|
|
777
|
-
* Get the value of a property on an element
|
|
778
|
-
* @param target Target element
|
|
779
|
-
* @param property Property to get
|
|
780
|
-
* @returns Property value
|
|
781
|
-
*/
|
|
782
|
-
function getProperty(target, property) {
|
|
783
|
-
if (isHTMLOrSVGElement(target) && typeof property === "string") return getPropertyValue(target, property);
|
|
784
|
-
}
|
|
785
|
-
function getPropertyValue(element, property) {
|
|
786
|
-
let actual = property;
|
|
787
|
-
if (!(actual in element)) actual = camelCase(actual);
|
|
788
|
-
if (actual in element) return element[actual];
|
|
789
|
-
}
|
|
790
|
-
//#endregion
|
|
791
|
-
//#region src/property/set.property.ts
|
|
792
|
-
/**
|
|
793
|
-
* Set the values of one or more properties on an element
|
|
794
|
-
*
|
|
795
|
-
* Also updates attributes for boolean/dispatchable properties, and if `dispatch` is `true`, will dispatch events for dispatchable properties
|
|
796
|
-
* @param target Target element
|
|
797
|
-
* @param properties Properties to set
|
|
798
|
-
* @param dispatch Dispatch events for properties? _(defaults to `true`)_
|
|
799
|
-
*/
|
|
800
|
-
function setProperties(target, properties, dispatch) {
|
|
801
|
-
if (!isHTMLOrSVGElement(target) || !isPlainObject(properties)) return;
|
|
802
|
-
const shouldDispatch = dispatch !== false;
|
|
803
|
-
const keys = Object.keys(properties);
|
|
804
|
-
const { length } = keys;
|
|
805
|
-
for (let index = 0; index < length; index += 1) setPropertyValue(target, keys[index], properties[keys[index]], shouldDispatch);
|
|
806
|
-
}
|
|
807
|
-
function setProperty(target, property, value, dispatch) {
|
|
808
|
-
if (isHTMLOrSVGElement(target) && typeof property === "string") setPropertyValue(target, property, value, dispatch !== false);
|
|
809
|
-
}
|
|
810
|
-
function setPropertyValue(element, property, value, dispatch) {
|
|
811
|
-
if (booleanAttributesSet.has(property.toLowerCase()) || dispatchedAttributes.has(property)) setAttribute(element, property, value, dispatch);
|
|
812
|
-
else updateProperty(element, property, value, dispatch);
|
|
813
|
-
}
|
|
814
|
-
//#endregion
|
|
815
903
|
//#region src/create.ts
|
|
816
904
|
function createElement(tag, properties, attributes, styles) {
|
|
817
905
|
if (typeof tag !== "string") throw new TypeError(MESSAGE);
|
|
@@ -825,7 +913,7 @@ const MESSAGE = "Tag name must be a string";
|
|
|
825
913
|
//#endregion
|
|
826
914
|
//#region src/data.ts
|
|
827
915
|
function getData(element, keys, parseValues) {
|
|
828
|
-
if (!
|
|
916
|
+
if (!(element instanceof Element)) return;
|
|
829
917
|
const noParse = parseValues === false;
|
|
830
918
|
if (typeof keys === "string") {
|
|
831
919
|
const value = element.dataset[camelCase(keys)];
|
|
@@ -874,7 +962,7 @@ function addDelegatedListener(target, type, name, listener, passive) {
|
|
|
874
962
|
};
|
|
875
963
|
}
|
|
876
964
|
function delegatedEventHandler(event) {
|
|
877
|
-
const key =
|
|
965
|
+
const key = `@${event.type}${this ? EVENT_SUFFIX_PASSIVE : EVENT_SUFFIX_ACTIVE}`;
|
|
878
966
|
const items = event.composedPath();
|
|
879
967
|
const { length } = items;
|
|
880
968
|
let cancelled = false;
|
|
@@ -909,7 +997,7 @@ function delegatedEventHandler(event) {
|
|
|
909
997
|
}
|
|
910
998
|
}
|
|
911
999
|
function getDelegatedName(target, type, options) {
|
|
912
|
-
if (isEventTarget(target) && EVENT_TYPES.has(type) && !options.capture && !options.once && options.signal == null) return
|
|
1000
|
+
if (isEventTarget(target) && EVENT_TYPES.has(type) && !options.capture && !options.once && options.signal == null) return `@${type}${options.passive ? EVENT_SUFFIX_PASSIVE : EVENT_SUFFIX_ACTIVE}`;
|
|
913
1001
|
}
|
|
914
1002
|
function removeDelegatedListener(target, name, listener) {
|
|
915
1003
|
const handlers = target[name];
|
|
@@ -919,10 +1007,9 @@ function removeDelegatedListener(target, name, listener) {
|
|
|
919
1007
|
return true;
|
|
920
1008
|
}
|
|
921
1009
|
const DELEGATED = /* @__PURE__ */ new Set();
|
|
922
|
-
const EVENT_PREFIX = "@";
|
|
923
1010
|
const EVENT_SUFFIX_ACTIVE = ":active";
|
|
924
1011
|
const EVENT_SUFFIX_PASSIVE = ":passive";
|
|
925
|
-
const EVENT_TYPES = new Set([
|
|
1012
|
+
const EVENT_TYPES = /* @__PURE__ */ new Set([
|
|
926
1013
|
"beforeinput",
|
|
927
1014
|
"click",
|
|
928
1015
|
"dblclick",
|
|
@@ -959,7 +1046,7 @@ function createDispatchOptions(options) {
|
|
|
959
1046
|
}
|
|
960
1047
|
function createEvent(type, options) {
|
|
961
1048
|
const hasOptions = isPlainObject(options);
|
|
962
|
-
if (hasOptions &&
|
|
1049
|
+
if (hasOptions && "detail" in options) return new CustomEvent(type, {
|
|
963
1050
|
...createDispatchOptions(options),
|
|
964
1051
|
detail: options?.detail
|
|
965
1052
|
});
|
|
@@ -978,6 +1065,7 @@ function dispatch(target, type, options) {
|
|
|
978
1065
|
}
|
|
979
1066
|
/**
|
|
980
1067
|
* Get the X- and Y-coordinates from a pointer event
|
|
1068
|
+
*
|
|
981
1069
|
* @param event Pointer event
|
|
982
1070
|
* @returns X- and Y-coordinates
|
|
983
1071
|
*/
|
|
@@ -998,6 +1086,7 @@ function getPosition(event) {
|
|
|
998
1086
|
}
|
|
999
1087
|
/**
|
|
1000
1088
|
* Remove an event listener
|
|
1089
|
+
*
|
|
1001
1090
|
* @param target Event target
|
|
1002
1091
|
* @param type Type of event
|
|
1003
1092
|
* @param listener Event listener
|
|
@@ -1020,7 +1109,6 @@ function on(target, type, listener, options) {
|
|
|
1020
1109
|
target.removeEventListener(type, listener, extended);
|
|
1021
1110
|
};
|
|
1022
1111
|
}
|
|
1023
|
-
const PROPERTY_DETAIL = "detail";
|
|
1024
1112
|
//#endregion
|
|
1025
1113
|
//#region src/find/relative.ts
|
|
1026
1114
|
function findAncestor(origin, selector) {
|
|
@@ -1061,6 +1149,7 @@ function findRelatives(origin, selector, context) {
|
|
|
1061
1149
|
}
|
|
1062
1150
|
/**
|
|
1063
1151
|
* Get the distance between two elements _(i.e., the amount of nodes of between them)_
|
|
1152
|
+
*
|
|
1064
1153
|
* @param origin Origin element
|
|
1065
1154
|
* @param target Target element
|
|
1066
1155
|
* @returns Distance between elements, or `-1` if distance cannot be calculated
|
|
@@ -1143,10 +1232,42 @@ function findElements(selector, context) {
|
|
|
1143
1232
|
return findElementOrElements(selector, context, false);
|
|
1144
1233
|
}
|
|
1145
1234
|
/**
|
|
1235
|
+
* Get elements from an event position
|
|
1236
|
+
*
|
|
1237
|
+
* @param position Event position
|
|
1238
|
+
* @returns Elements at the event position
|
|
1239
|
+
*/
|
|
1240
|
+
function getElementFromPosition(position) {
|
|
1241
|
+
if (!isEventPosition(position) || typeof document.elementFromPoint !== "function") return [];
|
|
1242
|
+
const { x, y } = position;
|
|
1243
|
+
const elements = [];
|
|
1244
|
+
const events = [];
|
|
1245
|
+
let current;
|
|
1246
|
+
while (true) {
|
|
1247
|
+
current = document.elementFromPoint(x, y);
|
|
1248
|
+
if (current == null || elements.indexOf(current) !== -1) break;
|
|
1249
|
+
if (!(current instanceof HTMLElement)) continue;
|
|
1250
|
+
elements.push(current);
|
|
1251
|
+
events.push({
|
|
1252
|
+
value: current.style.getPropertyValue(STYLE_POINTER_EVENTS),
|
|
1253
|
+
priority: current.style.getPropertyPriority(STYLE_POINTER_EVENTS)
|
|
1254
|
+
});
|
|
1255
|
+
current.style.setProperty(STYLE_POINTER_EVENTS, STYLE_NONE$1, STYLE_IMPORTANT);
|
|
1256
|
+
}
|
|
1257
|
+
const { length } = elements;
|
|
1258
|
+
for (let index = 0; index < length; index += 1) {
|
|
1259
|
+
const element = elements[index];
|
|
1260
|
+
const event = events[index];
|
|
1261
|
+
if (element instanceof HTMLElement) element.style.setProperty(STYLE_POINTER_EVENTS, event.value ?? "", event.priority);
|
|
1262
|
+
}
|
|
1263
|
+
return elements;
|
|
1264
|
+
}
|
|
1265
|
+
/**
|
|
1146
1266
|
* Get the most specific element under the pointer
|
|
1147
1267
|
*
|
|
1148
1268
|
* - Ignores elements with `pointer-events: none` and `visibility: hidden`
|
|
1149
1269
|
* - _(If `skipIgnore` is `true`, no elements are ignored)_
|
|
1270
|
+
*
|
|
1150
1271
|
* @param skipIgnore Skip ignored elements?
|
|
1151
1272
|
* @returns Found element or `null`
|
|
1152
1273
|
*/
|
|
@@ -1168,13 +1289,16 @@ function isContext(value) {
|
|
|
1168
1289
|
const QUERY_SELECTOR_ALL = "querySelectorAll";
|
|
1169
1290
|
const QUERY_SELECTOR_SINGLE = "querySelector";
|
|
1170
1291
|
const STYLE_HIDDEN$1 = "hidden";
|
|
1292
|
+
const STYLE_IMPORTANT = "important";
|
|
1171
1293
|
const STYLE_NONE$1 = "none";
|
|
1294
|
+
const STYLE_POINTER_EVENTS = "pointer-events";
|
|
1172
1295
|
const SUFFIX_HOVER = ":hover";
|
|
1173
1296
|
const TAG_HEAD = "HEAD";
|
|
1174
1297
|
//#endregion
|
|
1175
1298
|
//#region src/focusable.ts
|
|
1176
1299
|
/**
|
|
1177
1300
|
* Get a list of focusable elements within a parent element
|
|
1301
|
+
*
|
|
1178
1302
|
* @param parent Parent element
|
|
1179
1303
|
* @returns Focusable elements
|
|
1180
1304
|
*/
|
|
@@ -1189,6 +1313,7 @@ function getItem(element, tabbable) {
|
|
|
1189
1313
|
}
|
|
1190
1314
|
/**
|
|
1191
1315
|
* Get a list of tabbable elements within a parent element
|
|
1316
|
+
*
|
|
1192
1317
|
* @param parent Parent element
|
|
1193
1318
|
* @returns Tabbable elements
|
|
1194
1319
|
*/
|
|
@@ -1248,6 +1373,7 @@ function isEditable(element) {
|
|
|
1248
1373
|
}
|
|
1249
1374
|
/**
|
|
1250
1375
|
* Is the element focusable?
|
|
1376
|
+
*
|
|
1251
1377
|
* @param element Element to check
|
|
1252
1378
|
* @returns `true` if focusable, otherwise `false`
|
|
1253
1379
|
*/
|
|
@@ -1283,6 +1409,7 @@ function isSummarised(item) {
|
|
|
1283
1409
|
}
|
|
1284
1410
|
/**
|
|
1285
1411
|
* Is the element tabbable?
|
|
1412
|
+
*
|
|
1286
1413
|
* @param element Element to check
|
|
1287
1414
|
* @returns `true` if tabbable, otherwise `false`
|
|
1288
1415
|
*/
|
|
@@ -1489,8 +1616,9 @@ html.clear = () => {
|
|
|
1489
1616
|
templates.clear();
|
|
1490
1617
|
};
|
|
1491
1618
|
/**
|
|
1492
|
-
* Remove cached template element for an
|
|
1493
|
-
*
|
|
1619
|
+
* Remove cached template element for an _HTML_ string or _ID_
|
|
1620
|
+
*
|
|
1621
|
+
* @param template _HTML_ string or ID for a template element
|
|
1494
1622
|
*/
|
|
1495
1623
|
html.remove = (template) => {
|
|
1496
1624
|
templates.delete(template);
|
|
@@ -1513,6 +1641,7 @@ function replaceComments(origin, replacements) {
|
|
|
1513
1641
|
}
|
|
1514
1642
|
/**
|
|
1515
1643
|
* Sanitize one or more nodes, recursively
|
|
1644
|
+
*
|
|
1516
1645
|
* @param value Node or nodes to sanitize
|
|
1517
1646
|
* @param options Sanitization options
|
|
1518
1647
|
* @returns Sanitized nodes
|
|
@@ -1529,6 +1658,28 @@ const TEMPLATE_TAG = "template";
|
|
|
1529
1658
|
const TEMPORARY_ELEMENT = "<toretto-temporary></toretto-temporary>";
|
|
1530
1659
|
const templates = new SizedMap(128);
|
|
1531
1660
|
let parser;
|
|
1532
|
-
window.templates = templates;
|
|
1533
1661
|
//#endregion
|
|
1534
|
-
|
|
1662
|
+
//#region src/is.ts
|
|
1663
|
+
/**
|
|
1664
|
+
* Is the value a child node?
|
|
1665
|
+
*
|
|
1666
|
+
* @param value Value to check
|
|
1667
|
+
* @returns `true` if it's a child node, otherwise `false`
|
|
1668
|
+
*/
|
|
1669
|
+
function isChildNode(value) {
|
|
1670
|
+
return value instanceof Node && CHILD_NODE_TYPES.has(value.nodeType);
|
|
1671
|
+
}
|
|
1672
|
+
function isInDocument(node, doc) {
|
|
1673
|
+
if (!(node instanceof Node)) return false;
|
|
1674
|
+
if (!(doc instanceof Document)) return node.ownerDocument?.contains(node) ?? true;
|
|
1675
|
+
return node.ownerDocument == null ? node === doc : node.ownerDocument === doc && doc.contains(node);
|
|
1676
|
+
}
|
|
1677
|
+
const CHILD_NODE_TYPES = /* @__PURE__ */ new Set([
|
|
1678
|
+
Node.ELEMENT_NODE,
|
|
1679
|
+
Node.TEXT_NODE,
|
|
1680
|
+
Node.PROCESSING_INSTRUCTION_NODE,
|
|
1681
|
+
Node.COMMENT_NODE,
|
|
1682
|
+
Node.DOCUMENT_TYPE_NODE
|
|
1683
|
+
]);
|
|
1684
|
+
//#endregion
|
|
1685
|
+
export { findElement as $, findElement, findElements as $$, findElements, booleanAttributes, createElement, dispatch, findAncestor, findRelatives, getAria, getAttribute, getAttributes, getData, getDistance, getElementFromPosition, getElementUnderPointer, getFocusable, getPosition, getProperties, getProperty, getRole, getStyle, getStyles, getTabbable, getTextDirection, html, isBadAttribute, isBooleanAttribute, isChildNode, isEventPosition, isEventTarget, isFocusable, isHTMLOrSVGElement, isInDocument, isInputElement, isInvalidBooleanAttribute, isTabbable, off, on, sanitize, setAria, setAttribute, setAttributes, setData, setProperties, setProperty, setRole, setStyle, setStyles, supportsTouch, toggleStyles };
|