@oscarpalmer/toretto 0.32.0 → 0.33.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.
@@ -25,6 +25,9 @@ var touch_default = (() => {
25
25
  } });
26
26
  return instance;
27
27
  })();
28
+ function isNumber(value) {
29
+ return typeof value === "number" && !Number.isNaN(value);
30
+ }
28
31
  function isPlainObject(value) {
29
32
  if (value === null || typeof value !== "object") return false;
30
33
  if (Symbol.toStringTag in value || Symbol.iterator in value) return false;
@@ -46,12 +49,12 @@ new Set([
46
49
  ]);
47
50
  function compact(array, strict) {
48
51
  if (!Array.isArray(array)) return [];
52
+ if (strict === true) return array.filter(Boolean);
49
53
  const { length } = array;
50
- const isStrict = strict ?? false;
51
54
  const compacted = [];
52
55
  for (let index = 0; index < length; index += 1) {
53
56
  const item = array[index];
54
- if (isStrict && !!item || !isStrict && item != null) compacted.push(item);
57
+ if (item != null) compacted.push(item);
55
58
  }
56
59
  return compacted;
57
60
  }
@@ -63,75 +66,81 @@ function getString(value) {
63
66
  const asString = String(value.valueOf?.() ?? value);
64
67
  return asString.startsWith("[object ") ? JSON.stringify(value) : asString;
65
68
  }
69
+ function ignoreKey(key) {
70
+ return EXPRESSION_IGNORED.test(key);
71
+ }
66
72
  function join(value, delimiter) {
67
73
  return compact(value).map(getString).join(typeof delimiter === "string" ? delimiter : "");
68
74
  }
69
75
  function words(value) {
70
76
  return typeof value === "string" ? value.match(EXPRESSION_WORDS) ?? [] : [];
71
77
  }
78
+ var EXPRESSION_IGNORED = /(^|\.)(__proto__|constructor|prototype)(\.|$)/i;
72
79
  var EXPRESSION_WORDS = /[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;
73
80
  function isNullableOrWhitespace(value) {
74
81
  return value == null || EXPRESSION_WHITESPACE$1.test(getString(value));
75
82
  }
76
83
  var EXPRESSION_WHITESPACE$1 = /^\s*$/;
77
- function camelCase(value) {
78
- return toCase(value, "", true, false);
84
+ function isEventTarget(value) {
85
+ return typeof value === "object" && value != null && typeof value.addEventListener === "function" && typeof value.removeEventListener === "function" && typeof value.dispatchEvent === "function";
79
86
  }
80
- function capitalize(value) {
81
- if (typeof value !== "string" || value.length === 0) return "";
82
- return value.length === 1 ? value.toLocaleUpperCase() : `${value.charAt(0).toLocaleUpperCase()}${value.slice(1).toLocaleLowerCase()}`;
87
+ function isHTMLOrSVGElement(value) {
88
+ return value instanceof HTMLElement || value instanceof SVGElement;
83
89
  }
84
- function kebabCase(value) {
85
- return toCase(value, "-", false, false);
90
+ function isChildNode(value) {
91
+ return value instanceof Node && CHILD_NODE_TYPES.has(value.nodeType);
86
92
  }
87
- function toCase(value, delimiter, capitalizeAny, capitalizeFirst) {
88
- if (typeof value !== "string") return "";
89
- if (value.length < 1) return value;
90
- const parts = words(value);
91
- const partsLength = parts.length;
92
- const result = [];
93
- for (let partIndex = 0; partIndex < partsLength; partIndex += 1) {
94
- const items = parts[partIndex].replace(EXPRESSION_ACRONYM, (full, one, two, three) => three === "s" ? full : `${one}-${two}${three}`).replace(EXPRESSION_CAMEL_CASE, "$1-$2").split("-");
95
- const itemsLength = items.length;
96
- const partResult = [];
97
- let itemCount = 0;
98
- for (let itemIndex = 0; itemIndex < itemsLength; itemIndex += 1) {
99
- const item = items[itemIndex];
100
- if (item.length === 0) continue;
101
- if (!capitalizeAny || itemCount === 0 && partIndex === 0 && !capitalizeFirst) partResult.push(item.toLocaleLowerCase());
102
- else partResult.push(capitalize(item));
103
- itemCount += 1;
104
- }
105
- result.push(join(partResult, delimiter));
106
- }
107
- return join(result, delimiter);
93
+ function isInDocument(node, doc) {
94
+ if (!(node instanceof Node)) return false;
95
+ if (!(doc instanceof Document)) return node.ownerDocument?.contains(node) ?? true;
96
+ return node.ownerDocument == null ? node === doc : node.ownerDocument === doc && doc.contains(node);
108
97
  }
109
- var EXPRESSION_CAMEL_CASE = /(\p{Ll})(\p{Lu})/gu;
110
- var EXPRESSION_ACRONYM = /(\p{Lu}*)(\p{Lu})(\p{Ll}+)/gu;
111
- function parse(value, reviver) {
112
- try {
113
- return JSON.parse(value, reviver);
114
- } catch {
98
+ const CHILD_NODE_TYPES = new Set([
99
+ Node.ELEMENT_NODE,
100
+ Node.TEXT_NODE,
101
+ Node.PROCESSING_INSTRUCTION_NODE,
102
+ Node.COMMENT_NODE,
103
+ Node.DOCUMENT_TYPE_NODE
104
+ ]);
105
+ function setElementValue(element, first, second, third, callback) {
106
+ if (!isHTMLOrSVGElement(element)) return;
107
+ if (typeof first === "string") setElementValues(element, first, second, third, callback);
108
+ else if (isAttribute(first)) setElementValues(element, first.name, first.value, third, callback);
109
+ }
110
+ function setElementValues(element, first, second, third, callback) {
111
+ if (!isHTMLOrSVGElement(element)) return;
112
+ if (typeof first === "string") {
113
+ callback(element, first, second, third);
115
114
  return;
116
115
  }
116
+ const isArray = Array.isArray(first);
117
+ if (!isArray && !(typeof first === "object" && first !== null)) return;
118
+ const entries = isArray ? first : Object.entries(first).map(([name, value]) => ({
119
+ name,
120
+ value
121
+ }));
122
+ const { length } = entries;
123
+ for (let index = 0; index < length; index += 1) {
124
+ const entry = entries[index];
125
+ if (typeof entry === "object" && typeof entry?.name === "string") callback(element, entry.name, entry.value, third);
126
+ }
117
127
  }
118
- function isEventTarget(value) {
119
- return typeof value === "object" && value != null && typeof value.addEventListener === "function" && typeof value.removeEventListener === "function" && typeof value.dispatchEvent === "function";
120
- }
121
- function isHTMLOrSVGElement(value) {
122
- return value instanceof HTMLElement || value instanceof SVGElement;
128
+ function updateElementValue(element, key, value, set, remove, isBoolean, json) {
129
+ if (isBoolean ? value == null : isNullableOrWhitespace(value)) remove.call(element, key);
130
+ else set.call(element, key, json ? JSON.stringify(value) : String(value));
123
131
  }
124
132
  function badAttributeHandler(name, value) {
125
- if (name == null || value == null) return true;
133
+ if (typeof name !== "string" || name.trim().length === 0 || typeof value !== "string") return true;
126
134
  if (EXPRESSION_CLOBBERED_NAME.test(name) && (value in document || value in formElement) || EXPRESSION_EVENT_NAME.test(name)) return true;
127
135
  if (EXPRESSION_SKIP_NAME.test(name) || EXPRESSION_URI_VALUE.test(value) || isValidSourceAttribute(name, value)) return false;
128
136
  return EXPRESSION_DATA_OR_SCRIPT.test(value);
129
137
  }
130
138
  function booleanAttributeHandler(name, value) {
131
- if (name == null || value == null) return true;
132
- if (!booleanAttributesSet.has(name)) return false;
133
- const normalized = value.toLowerCase().trim();
134
- return !(normalized.length === 0 || normalized === name);
139
+ if (typeof name !== "string" || name.trim().length === 0 || typeof value !== "string") return true;
140
+ const normalizedName = name.toLowerCase();
141
+ if (!booleanAttributesSet.has(normalizedName)) return false;
142
+ const normalized = value.toLowerCase();
143
+ return !(normalized.length === 0 || normalized === normalizedName);
135
144
  }
136
145
  function decodeAttribute(value) {
137
146
  textArea ??= document.createElement("textarea");
@@ -152,7 +161,7 @@ function handleAttribute(callback, decode, first, second) {
152
161
  return callback(name, value?.replace(EXPRESSION_WHITESPACE, ""));
153
162
  }
154
163
  function isAttribute(value) {
155
- return value instanceof Attr || isPlainObject(value) && typeof value.name === "string" && typeof value.value === "string";
164
+ return value instanceof Attr || isPlainObject(value) && typeof value.name === "string" && "value" in value;
156
165
  }
157
166
  function _isBadAttribute(first, second, decode) {
158
167
  return handleAttribute(badAttributeHandler, decode, first, second);
@@ -166,26 +175,21 @@ function _isEmptyNonBooleanAttribute(first, second, decode) {
166
175
  function _isInvalidBooleanAttribute(first, second, decode) {
167
176
  return handleAttribute(booleanAttributeHandler, decode, first, second);
168
177
  }
169
- function isProperty(value) {
170
- return isPlainObject(value) && typeof value.name === "string";
171
- }
172
178
  function isValidSourceAttribute(name, value) {
173
179
  return EXPRESSION_SOURCE_NAME.test(name) && EXPRESSION_SOURCE_VALUE.test(value);
174
180
  }
175
- function updateAttribute(element, name, value) {
176
- const isBoolean = booleanAttributesSet.has(name.toLowerCase());
177
- if (isBoolean) updateProperty(element, name, value);
178
- if (isBoolean ? value !== true : value == null) element.removeAttribute(name);
179
- else element.setAttribute(name, isBoolean ? "" : getString(value));
180
- }
181
- function updateProperty(element, name, value) {
182
- const actual = name.toLowerCase();
183
- element[actual] = value === "" || typeof value === "string" && value.toLowerCase() === actual || value === true;
181
+ function updateAttribute(element, name, value, dispatch$1) {
182
+ const normalizedName = name.toLowerCase();
183
+ const isBoolean = booleanAttributesSet.has(normalizedName);
184
+ const next = isBoolean ? value === true || typeof value === "string" && (value === "" || value.toLowerCase() === normalizedName) : value == null ? "" : value;
185
+ if (name in element) updateProperty(element, normalizedName, next, dispatch$1);
186
+ updateElementValue(element, name, isBoolean ? next ? "" : null : value, element.setAttribute, element.removeAttribute, isBoolean, false);
184
187
  }
185
- function updateValue(element, first, second) {
186
- if (!isHTMLOrSVGElement(element)) return;
187
- if (isProperty(first)) updateAttribute(element, first.name, first.value);
188
- else if (typeof first === "string") updateAttribute(element, first, second);
188
+ function updateProperty(element, name, value, dispatch$1) {
189
+ if (Object.is(element[name], value)) return;
190
+ element[name] = value;
191
+ const event = dispatch$1 !== false && elementEvents[element.tagName]?.[name];
192
+ if (typeof event === "string") element.dispatchEvent(new Event(event, { bubbles: true }));
189
193
  }
190
194
  const EXPRESSION_CLOBBERED_NAME = /^(id|name)$/i;
191
195
  const EXPRESSION_DATA_OR_SCRIPT = /^(?:data|\w+script):/i;
@@ -222,8 +226,261 @@ const booleanAttributes = Object.freeze([
222
226
  "selected"
223
227
  ]);
224
228
  const booleanAttributesSet = new Set(booleanAttributes);
229
+ const elementEvents = {
230
+ DETAILS: { open: "toggle" },
231
+ INPUT: {
232
+ checked: "change",
233
+ value: "input"
234
+ },
235
+ SELECT: { value: "change" },
236
+ TEXTAREA: { value: "input" }
237
+ };
225
238
  const formElement = document.createElement("form");
226
239
  let textArea;
240
+ function noop() {}
241
+ function calculate() {
242
+ return new Promise((resolve) => {
243
+ const values = [];
244
+ let last;
245
+ function step(now) {
246
+ if (last != null) values.push(now - last);
247
+ last = now;
248
+ if (values.length >= TOTAL) resolve(values.sort().slice(TRIM_PART, -TRIM_PART).reduce((first, second) => first + second, 0) / (values.length - TRIM_TOTAL));
249
+ else requestAnimationFrame(step);
250
+ }
251
+ requestAnimationFrame(step);
252
+ });
253
+ }
254
+ var TOTAL = 10;
255
+ var TRIM_PART = 2;
256
+ var TRIM_TOTAL = 4;
257
+ await calculate();
258
+ function clamp(value, minimum, maximum, loop) {
259
+ if (![
260
+ value,
261
+ minimum,
262
+ maximum
263
+ ].every(isNumber)) return NaN;
264
+ if (value < minimum) return loop === true ? maximum : minimum;
265
+ return value > maximum ? loop === true ? minimum : maximum : value;
266
+ }
267
+ var SizedMap = class extends Map {
268
+ #maximumSize;
269
+ get full() {
270
+ return this.size >= this.#maximumSize;
271
+ }
272
+ get maximum() {
273
+ return this.#maximumSize;
274
+ }
275
+ constructor(first, second) {
276
+ const maximum = getMaximum(first, second);
277
+ super();
278
+ this.#maximumSize = maximum;
279
+ if (Array.isArray(first)) {
280
+ const { length } = first;
281
+ if (length <= maximum) for (let index = 0; index < length; index += 1) this.set(...first[index]);
282
+ else for (let index = 0; index < maximum; index += 1) this.set(...first[length - maximum + index]);
283
+ }
284
+ }
285
+ get(key) {
286
+ const value = super.get(key);
287
+ if (value !== void 0 || this.has(key)) this.set(key, value);
288
+ return value;
289
+ }
290
+ set(key, value) {
291
+ if (this.has(key)) this.delete(key);
292
+ else if (this.size >= this.#maximumSize) this.delete(this.keys().next().value);
293
+ return super.set(key, value);
294
+ }
295
+ };
296
+ function getMaximum(first, second) {
297
+ let actual;
298
+ if (typeof first === "number") actual = first;
299
+ else actual = typeof second === "number" ? second : MAXIMUM_DEFAULT;
300
+ return clamp(actual, 1, MAXIMUM_ABSOLUTE);
301
+ }
302
+ var MAXIMUM_ABSOLUTE = 16777216;
303
+ var MAXIMUM_DEFAULT = 1048576;
304
+ var Memoized = class {
305
+ #state;
306
+ get maximum() {
307
+ return this.#state.cache?.maximum ?? NaN;
308
+ }
309
+ get size() {
310
+ return this.#state.cache?.size ?? NaN;
311
+ }
312
+ constructor(callback, options) {
313
+ const cache = new SizedMap(options.cacheSize);
314
+ const getter = (...parameters) => {
315
+ const key = options.cacheKey?.(...parameters) ?? (parameters.length === 1 ? parameters[0] : join(parameters.map(getString), "_"));
316
+ if (cache.has(key)) return cache.get(key);
317
+ const value = callback(...parameters);
318
+ cache.set(key, value);
319
+ return value;
320
+ };
321
+ this.#state = {
322
+ cache,
323
+ getter
324
+ };
325
+ }
326
+ clear() {
327
+ this.#state.cache?.clear();
328
+ }
329
+ delete(key) {
330
+ return this.#state.cache?.delete(key) ?? false;
331
+ }
332
+ destroy() {
333
+ this.#state.cache?.clear();
334
+ this.#state.cache = void 0;
335
+ this.#state.getter = void 0;
336
+ }
337
+ get(key) {
338
+ return this.#state.cache?.get(key);
339
+ }
340
+ has(key) {
341
+ return this.#state.cache?.has(key) ?? false;
342
+ }
343
+ run(...parameters) {
344
+ if (this.#state.cache == null || this.#state.getter == null) throw new Error("The Memoized instance has been destroyed");
345
+ return this.#state.getter(...parameters);
346
+ }
347
+ };
348
+ function getMemoizationOptions(input) {
349
+ const { cacheKey, cacheSize } = isPlainObject(input) ? input : {};
350
+ return {
351
+ cacheKey: typeof cacheKey === "function" ? cacheKey : void 0,
352
+ cacheSize: typeof cacheSize === "number" && cacheSize > 0 ? cacheSize : DEFAULT_CACHE_SIZE
353
+ };
354
+ }
355
+ function memoize(callback, options) {
356
+ return new Memoized(callback, getMemoizationOptions(options));
357
+ }
358
+ var DEFAULT_CACHE_SIZE = 1024;
359
+ function camelCase(value) {
360
+ return toCase(TYPE_CAMEL, value, true, false);
361
+ }
362
+ function capitalize(value) {
363
+ if (typeof value !== "string" || value.length === 0) return "";
364
+ memoizedCapitalize ??= memoize((v) => v.length === 1 ? v.toLocaleUpperCase() : `${v.charAt(0).toLocaleUpperCase()}${v.slice(1).toLocaleLowerCase()}`);
365
+ return memoizedCapitalize.run(value);
366
+ }
367
+ function kebabCase(value) {
368
+ return toCase(TYPE_KEBAB, value, false, false);
369
+ }
370
+ function toCase(type, value, capitalizeAny, capitalizeFirst) {
371
+ memoizers[type] ??= memoize(toCaseCallback.bind({
372
+ type,
373
+ capitalizeAny,
374
+ capitalizeFirst
375
+ }));
376
+ return memoizers[type].run(value);
377
+ }
378
+ function toCaseCallback(value) {
379
+ if (typeof value !== "string") return "";
380
+ if (value.length < 1) return value;
381
+ const { capitalizeAny, capitalizeFirst, type } = this;
382
+ const parts = words(value);
383
+ const partsLength = parts.length;
384
+ const result = [];
385
+ for (let partIndex = 0; partIndex < partsLength; partIndex += 1) {
386
+ const items = parts[partIndex].replace(EXPRESSION_ACRONYM, (full, one, two, three) => three === "s" ? full : `${one}-${two}${three}`).replace(EXPRESSION_CAMEL_CASE, REPLACEMENT_CAMEL_CASE).split("-");
387
+ const itemsLength = items.length;
388
+ const partResult = [];
389
+ let itemCount = 0;
390
+ for (let itemIndex = 0; itemIndex < itemsLength; itemIndex += 1) {
391
+ const item = items[itemIndex];
392
+ if (item.length === 0) continue;
393
+ if (!capitalizeAny || itemCount === 0 && partIndex === 0 && !capitalizeFirst) partResult.push(item.toLocaleLowerCase());
394
+ else partResult.push(capitalize(item));
395
+ itemCount += 1;
396
+ }
397
+ result.push(join(partResult, delimiters[type]));
398
+ }
399
+ return join(result, delimiters[type]);
400
+ }
401
+ var EXPRESSION_CAMEL_CASE = /(\p{Ll})(\p{Lu})/gu;
402
+ var EXPRESSION_ACRONYM = /(\p{Lu}*)(\p{Lu})(\p{Ll}+)/gu;
403
+ var REPLACEMENT_CAMEL_CASE = "$1-$2";
404
+ var TYPE_CAMEL = "camel";
405
+ var TYPE_KEBAB = "kebab";
406
+ var TYPE_PASCAL = "pascal";
407
+ var TYPE_SNAKE = "snake";
408
+ var delimiters = {
409
+ [TYPE_CAMEL]: "",
410
+ [TYPE_KEBAB]: "-",
411
+ [TYPE_PASCAL]: "",
412
+ [TYPE_SNAKE]: "_"
413
+ };
414
+ var memoizers = {};
415
+ var memoizedCapitalize;
416
+ function parse(value, reviver) {
417
+ try {
418
+ return JSON.parse(value, reviver);
419
+ } catch {
420
+ return;
421
+ }
422
+ }
423
+ function findKey(needle, haystack) {
424
+ const keys = Object.keys(haystack);
425
+ const index = keys.map((key) => key.toLowerCase()).indexOf(needle.toLowerCase());
426
+ return index > -1 ? keys[index] : needle;
427
+ }
428
+ function getPaths(path, lowercase) {
429
+ const normalized = lowercase ? path.toLowerCase() : path;
430
+ if (!EXPRESSION_NESTED.test(normalized)) return normalized;
431
+ return normalized.replace(EXPRESSION_BRACKET, ".$1").replace(EXPRESSION_DOTS, "").split(".");
432
+ }
433
+ function handleValue(data, path, value, get, ignoreCase) {
434
+ if (typeof data === "object" && data !== null && !ignoreKey(path)) {
435
+ const key = ignoreCase ? findKey(path, data) : path;
436
+ if (get) return data[key];
437
+ data[key] = value;
438
+ }
439
+ }
440
+ var EXPRESSION_BRACKET = /\[(\w+)\]/g;
441
+ var EXPRESSION_DOTS = /^\.|\.$/g;
442
+ var EXPRESSION_NESTED = /\.|\[\w+\]/;
443
+ function getValue(data, path, ignoreCase) {
444
+ if (typeof data !== "object" || data === null || typeof path !== "string" || path.trim().length === 0) return;
445
+ const shouldIgnoreCase = ignoreCase === true;
446
+ const paths = getPaths(path, shouldIgnoreCase);
447
+ if (typeof paths === "string") return handleValue(data, paths, null, true, shouldIgnoreCase);
448
+ const { length } = paths;
449
+ let index = 0;
450
+ let value = data;
451
+ while (index < length && value != null) value = handleValue(value, paths[index++], null, true, shouldIgnoreCase);
452
+ return value;
453
+ }
454
+ function getTemplateOptions(input) {
455
+ const options = isPlainObject(input) ? input : {};
456
+ return {
457
+ ignoreCase: options.ignoreCase === true,
458
+ pattern: options.pattern instanceof RegExp ? options.pattern : EXPRESSION_VARIABLE
459
+ };
460
+ }
461
+ function handleTemplate(value, pattern, ignoreCase, variables) {
462
+ if (typeof value !== "string") return "";
463
+ if (typeof variables !== "object" || variables === null) return value;
464
+ const values = {};
465
+ return value.replace(pattern, (_, key) => {
466
+ if (values[key] == null) {
467
+ const templateValue = getValue(variables, key, ignoreCase);
468
+ values[key] = templateValue == null ? "" : getString(templateValue);
469
+ }
470
+ return values[key];
471
+ });
472
+ }
473
+ var template = ((value, variables, options) => {
474
+ const { ignoreCase, pattern } = getTemplateOptions(options);
475
+ return handleTemplate(value, pattern, ignoreCase, variables);
476
+ });
477
+ template.initialize = (options) => {
478
+ const { ignoreCase, pattern } = getTemplateOptions(options);
479
+ return (value, variables) => {
480
+ return handleTemplate(value, pattern, ignoreCase, variables);
481
+ };
482
+ };
483
+ var EXPRESSION_VARIABLE = /{{([\s\S]+?)}}/g;
227
484
  function getBoolean(value, defaultValue) {
228
485
  return typeof value === "boolean" ? value : defaultValue ?? false;
229
486
  }
@@ -232,8 +489,8 @@ function getStyleValue(element, property, computed) {
232
489
  return computed ? getComputedStyle(element)[name] : element.style[name];
233
490
  }
234
491
  const EXPRESSION_DATA_PREFIX = /^data-/i;
235
- function setAttribute(element, first, second) {
236
- updateValue(element, first, second);
492
+ function setAttribute(element, first, second, third) {
493
+ setElementValue(element, first, second, third, updateAttribute);
237
494
  }
238
495
  function isBadAttribute(first, second) {
239
496
  return _isBadAttribute(first, second, true);
@@ -247,36 +504,6 @@ function isEmptyNonBooleanAttribute(first, second) {
247
504
  function isInvalidBooleanAttribute(first, second) {
248
505
  return _isInvalidBooleanAttribute(first, second, true);
249
506
  }
250
- function isChildNode(value) {
251
- return value instanceof Node && CHILD_NODE_TYPES.has(value.nodeType);
252
- }
253
- function isInDocument(node, doc) {
254
- if (!(node instanceof Node)) return false;
255
- if (!(doc instanceof Document)) return node.ownerDocument?.contains(node) ?? true;
256
- return node.ownerDocument == null ? node === doc : node.ownerDocument === doc && doc.contains(node);
257
- }
258
- const CHILD_NODE_TYPES = new Set([
259
- Node.ELEMENT_NODE,
260
- Node.TEXT_NODE,
261
- Node.PROCESSING_INSTRUCTION_NODE,
262
- Node.COMMENT_NODE,
263
- Node.DOCUMENT_TYPE_NODE
264
- ]);
265
- function setElementValues(element, first, second, callback) {
266
- if (!isHTMLOrSVGElement(element)) return;
267
- if (isPlainObject(first)) {
268
- const entries = Object.entries(first);
269
- const { length } = entries;
270
- for (let index = 0; index < length; index += 1) {
271
- const [key, value] = entries[index];
272
- callback(element, key, value);
273
- }
274
- } else if (typeof first === "string") callback(element, first, second);
275
- }
276
- function updateElementValue(element, key, value, set, remove, json) {
277
- if (isNullableOrWhitespace(value)) remove.call(element, key);
278
- else set.call(element, key, json ? JSON.stringify(value) : String(value));
279
- }
280
507
  function getData(element, keys, parseValues) {
281
508
  if (!isHTMLOrSVGElement(element)) return;
282
509
  const shouldParse = parseValues !== false;
@@ -299,30 +526,12 @@ function getName(original) {
299
526
  return `${ATTRIBUTE_DATA_PREFIX}${kebabCase(original).replace(EXPRESSION_DATA_PREFIX, "")}`;
300
527
  }
301
528
  function setData(element, first, second) {
302
- setElementValues(element, first, second, updateDataAttribute);
529
+ setElementValues(element, first, second, null, updateDataAttribute);
303
530
  }
304
531
  function updateDataAttribute(element, key, value) {
305
- updateElementValue(element, getName(key), value, element.setAttribute, element.removeAttribute, true);
532
+ updateElementValue(element, getName(key), value, element.setAttribute, element.removeAttribute, false, true);
306
533
  }
307
534
  const ATTRIBUTE_DATA_PREFIX = "data-";
308
- function noop() {}
309
- function calculate() {
310
- return new Promise((resolve) => {
311
- const values = [];
312
- let last;
313
- function step(now) {
314
- if (last != null) values.push(now - last);
315
- last = now;
316
- if (values.length >= CALCULATION_TOTAL) resolve(values.sort().slice(CALCULATION_TRIM_PART, -CALCULATION_TRIM_PART).reduce((first, second) => first + second, 0) / (values.length - CALCULATION_TRIM_TOTAL));
317
- else requestAnimationFrame(step);
318
- }
319
- requestAnimationFrame(step);
320
- });
321
- }
322
- var CALCULATION_TOTAL = 10;
323
- var CALCULATION_TRIM_PART = 2;
324
- var CALCULATION_TRIM_TOTAL = 4;
325
- calculate().then((value) => {});
326
535
  function addDelegatedHandler(doc, type, name, passive) {
327
536
  if (DELEGATED.has(name)) return;
328
537
  DELEGATED.add(name);
@@ -790,18 +999,18 @@ function createHtml(value) {
790
999
  return parsed.body.innerHTML;
791
1000
  }
792
1001
  function createTemplate(value, options) {
793
- const template = document.createElement(TEMPLATE_TAG);
794
- template.innerHTML = createHtml(value);
795
- if (typeof value === "string" && options.cache) templates[value] = template;
796
- return template;
1002
+ const template$1 = document.createElement(TEMPLATE_TAG);
1003
+ template$1.innerHTML = createHtml(value);
1004
+ if (typeof value === "string" && options.cache) templates[value] = template$1;
1005
+ return template$1;
797
1006
  }
798
1007
  function getHtml(value) {
799
1008
  return `${TEMPORARY_ELEMENT}${typeof value === "string" ? value : value.innerHTML}${TEMPORARY_ELEMENT}`;
800
1009
  }
801
1010
  function getNodes(value, options) {
802
1011
  if (typeof value !== "string" && !(value instanceof HTMLTemplateElement)) return [];
803
- const template = getTemplate(value, options);
804
- return template == null ? [] : [...template.content.cloneNode(true).childNodes];
1012
+ const template$1 = getTemplate(value, options);
1013
+ return template$1 == null ? [] : [...template$1.content.cloneNode(true).childNodes];
805
1014
  }
806
1015
  function getOptions(input) {
807
1016
  const options = isPlainObject(input) ? input : {};
@@ -815,8 +1024,8 @@ function getParser() {
815
1024
  function getTemplate(value, options) {
816
1025
  if (value instanceof HTMLTemplateElement) return createTemplate(value, options);
817
1026
  if (value.trim().length === 0) return;
818
- let template = templates[value];
819
- if (template != null) return template;
1027
+ let template$1 = templates[value];
1028
+ if (template$1 != null) return template$1;
820
1029
  const element = EXPRESSION_ID.test(value) ? document.querySelector(`#${value}`) : null;
821
1030
  return createTemplate(element instanceof HTMLTemplateElement ? element : value, options);
822
1031
  }
@@ -826,14 +1035,14 @@ const html = ((value, options) => {
826
1035
  html.clear = () => {
827
1036
  templates = {};
828
1037
  };
829
- html.remove = (template) => {
830
- if (typeof template !== "string" || templates[template] == null) return;
1038
+ html.remove = (template$1) => {
1039
+ if (typeof template$1 !== "string" || templates[template$1] == null) return;
831
1040
  const keys = Object.keys(templates);
832
1041
  const { length } = keys;
833
1042
  const updated = {};
834
1043
  for (let index = 0; index < length; index += 1) {
835
1044
  const key = keys[index];
836
- if (key !== template) updated[key] = templates[key];
1045
+ if (key !== template$1) updated[key] = templates[key];
837
1046
  }
838
1047
  templates = updated;
839
1048
  };
@@ -868,10 +1077,10 @@ function getTextDirection(element, computed) {
868
1077
  return value === "rtl" ? value : "ltr";
869
1078
  }
870
1079
  function setStyle(element, property, value) {
871
- setElementValues(element, property, value, updateStyleProperty);
1080
+ setElementValues(element, property, value, null, updateStyleProperty);
872
1081
  }
873
1082
  function setStyles(element, styles) {
874
- setElementValues(element, styles, null, updateStyleProperty);
1083
+ setElementValues(element, styles, null, null, updateStyleProperty);
875
1084
  }
876
1085
  function toggleStyles(element, styles) {
877
1086
  function toggle(set) {
@@ -904,7 +1113,7 @@ function updateStyleProperty(element, key, value) {
904
1113
  this.style[property] = style;
905
1114
  }, function(property) {
906
1115
  this.style[property] = "";
907
- }, false);
1116
+ }, false, false);
908
1117
  }
909
1118
  const ATTRIBUTE_DIRECTION = "dir";
910
1119
  const EXPRESSION_DIRECTION = /^(ltr|rtl)$/i;
package/package.json CHANGED
@@ -4,19 +4,19 @@
4
4
  "url": "https://oscarpalmer.se"
5
5
  },
6
6
  "dependencies": {
7
- "@oscarpalmer/atoms": "^0.117"
7
+ "@oscarpalmer/atoms": "^0.119"
8
8
  },
9
9
  "description": "A collection of badass DOM utilities.",
10
10
  "devDependencies": {
11
11
  "@types/node": "^25",
12
12
  "@vitest/coverage-istanbul": "^4",
13
- "jsdom": "^27.3",
14
- "oxfmt": "^0.19",
15
- "oxlint": "^1.34",
16
- "rolldown": "1.0.0-beta.56",
13
+ "jsdom": "^27.4",
14
+ "oxfmt": "^0.21",
15
+ "oxlint": "^1.36",
16
+ "rolldown": "1.0.0-beta.57",
17
17
  "tslib": "^2.8",
18
18
  "typescript": "^5.9",
19
- "vite": "8.0.0-beta.2",
19
+ "vite": "8.0.0-beta.5",
20
20
  "vitest": "^4"
21
21
  },
22
22
  "exports": {
@@ -93,5 +93,5 @@
93
93
  },
94
94
  "type": "module",
95
95
  "types": "types/index.d.ts",
96
- "version": "0.32.0"
96
+ "version": "0.33.0"
97
97
  }