@oscarpalmer/toretto 0.37.0 → 0.37.2
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/find/relative.js +2 -2
- package/dist/toretto.full.js +23 -23
- package/package.json +7 -7
- package/src/find/relative.ts +2 -2
package/dist/find/relative.js
CHANGED
|
@@ -2,8 +2,8 @@ function findAncestor(origin, selector) {
|
|
|
2
2
|
const element = getElement(origin);
|
|
3
3
|
if (element == null || selector == null) return null;
|
|
4
4
|
if (typeof selector === "string") {
|
|
5
|
-
if (
|
|
6
|
-
return
|
|
5
|
+
if (Element.prototype.matches.call(element, selector)) return element;
|
|
6
|
+
return Element.prototype.closest.call(element, selector);
|
|
7
7
|
}
|
|
8
8
|
if (typeof selector !== "function") return null;
|
|
9
9
|
if (selector(element)) return element;
|
package/dist/toretto.full.js
CHANGED
|
@@ -165,17 +165,17 @@ function _isInvalidBooleanAttribute(first, second, decode) {
|
|
|
165
165
|
function isValidSourceAttribute(name, value) {
|
|
166
166
|
return EXPRESSION_SOURCE_NAME.test(name) && EXPRESSION_SOURCE_VALUE.test(value);
|
|
167
167
|
}
|
|
168
|
-
function updateAttribute(element, name, value, dispatch
|
|
168
|
+
function updateAttribute(element, name, value, dispatch) {
|
|
169
169
|
const normalizedName = name.toLowerCase();
|
|
170
170
|
const isBoolean = booleanAttributesSet.has(normalizedName);
|
|
171
171
|
const next = isBoolean ? value === true || typeof value === "string" && (value === "" || value.toLowerCase() === normalizedName) : value == null ? "" : value;
|
|
172
|
-
if (name in element) updateProperty(element, normalizedName, next, dispatch
|
|
172
|
+
if (name in element) updateProperty(element, normalizedName, next, dispatch);
|
|
173
173
|
updateElementValue(element, name, isBoolean ? next ? "" : null : value, element.setAttribute, element.removeAttribute, isBoolean, false);
|
|
174
174
|
}
|
|
175
|
-
function updateProperty(element, name, value, dispatch
|
|
175
|
+
function updateProperty(element, name, value, dispatch) {
|
|
176
176
|
if (Object.is(element[name], value)) return;
|
|
177
177
|
element[name] = value;
|
|
178
|
-
const event = dispatch
|
|
178
|
+
const event = dispatch !== false && elementEvents[element.tagName]?.[name];
|
|
179
179
|
if (typeof event === "string") element.dispatchEvent(new Event(event, { bubbles: true }));
|
|
180
180
|
}
|
|
181
181
|
const EXPRESSION_CLOBBERED_NAME = /^(id|name)$/i;
|
|
@@ -355,12 +355,12 @@ function kebabCase(value) {
|
|
|
355
355
|
return toCase("kebab", value, false, false);
|
|
356
356
|
}
|
|
357
357
|
function toCase(type, value, capitalizeAny, capitalizeFirst) {
|
|
358
|
-
|
|
358
|
+
caseMemoizers[type] ??= memoize(toCaseCallback.bind({
|
|
359
359
|
type,
|
|
360
360
|
capitalizeAny,
|
|
361
361
|
capitalizeFirst
|
|
362
362
|
}));
|
|
363
|
-
return
|
|
363
|
+
return caseMemoizers[type].run(value);
|
|
364
364
|
}
|
|
365
365
|
function toCaseCallback(value) {
|
|
366
366
|
if (typeof value !== "string") return "";
|
|
@@ -385,16 +385,16 @@ function toCaseCallback(value) {
|
|
|
385
385
|
}
|
|
386
386
|
return join(cased, delimiters[type]);
|
|
387
387
|
}
|
|
388
|
-
var EXPRESSION_CAMEL_CASE = /(\p{Ll})(\p{Lu})/gu;
|
|
389
|
-
var EXPRESSION_ACRONYM = /(\p{Lu}*)(\p{Lu})(\p{Ll}+)/gu;
|
|
390
|
-
var REPLACEMENT_CAMEL_CASE = "$1-$2";
|
|
391
388
|
var delimiters = {
|
|
392
389
|
camel: "",
|
|
393
390
|
kebab: "-",
|
|
394
391
|
pascal: "",
|
|
395
392
|
snake: "_"
|
|
396
393
|
};
|
|
397
|
-
var
|
|
394
|
+
var EXPRESSION_CAMEL_CASE = /(\p{Ll})(\p{Lu})/gu;
|
|
395
|
+
var EXPRESSION_ACRONYM = /(\p{Lu}*)(\p{Lu})(\p{Ll}+)/gu;
|
|
396
|
+
var caseMemoizers = {};
|
|
397
|
+
var REPLACEMENT_CAMEL_CASE = "$1-$2";
|
|
398
398
|
var memoizedCapitalize;
|
|
399
399
|
function parse(value, reviver) {
|
|
400
400
|
try {
|
|
@@ -659,8 +659,8 @@ function findAncestor(origin, selector) {
|
|
|
659
659
|
const element = getElement(origin);
|
|
660
660
|
if (element == null || selector == null) return null;
|
|
661
661
|
if (typeof selector === "string") {
|
|
662
|
-
if (
|
|
663
|
-
return
|
|
662
|
+
if (Element.prototype.matches.call(element, selector)) return element;
|
|
663
|
+
return Element.prototype.closest.call(element, selector);
|
|
664
664
|
}
|
|
665
665
|
if (typeof selector !== "function") return null;
|
|
666
666
|
if (selector(element)) return element;
|
|
@@ -987,18 +987,18 @@ function createHtml(value) {
|
|
|
987
987
|
return parsed.body.innerHTML;
|
|
988
988
|
}
|
|
989
989
|
function createTemplate(value, options) {
|
|
990
|
-
const template
|
|
991
|
-
template
|
|
992
|
-
if (typeof value === "string" && options.cache) templates[value] = template
|
|
993
|
-
return template
|
|
990
|
+
const template = document.createElement(TEMPLATE_TAG);
|
|
991
|
+
template.innerHTML = createHtml(value);
|
|
992
|
+
if (typeof value === "string" && options.cache) templates[value] = template;
|
|
993
|
+
return template;
|
|
994
994
|
}
|
|
995
995
|
function getHtml(value) {
|
|
996
996
|
return `${TEMPORARY_ELEMENT}${typeof value === "string" ? value : value.innerHTML}${TEMPORARY_ELEMENT}`;
|
|
997
997
|
}
|
|
998
998
|
function getNodes(value, options) {
|
|
999
999
|
if (typeof value !== "string" && !(value instanceof HTMLTemplateElement)) return [];
|
|
1000
|
-
const template
|
|
1001
|
-
return template
|
|
1000
|
+
const template = getTemplate(value, options);
|
|
1001
|
+
return template == null ? [] : [...template.content.cloneNode(true).childNodes];
|
|
1002
1002
|
}
|
|
1003
1003
|
function getOptions(input) {
|
|
1004
1004
|
const options = isPlainObject(input) ? input : {};
|
|
@@ -1012,8 +1012,8 @@ function getParser() {
|
|
|
1012
1012
|
function getTemplate(value, options) {
|
|
1013
1013
|
if (value instanceof HTMLTemplateElement) return createTemplate(value, options);
|
|
1014
1014
|
if (value.trim().length === 0) return;
|
|
1015
|
-
let template
|
|
1016
|
-
if (template
|
|
1015
|
+
let template = templates[value];
|
|
1016
|
+
if (template != null) return template;
|
|
1017
1017
|
const element = EXPRESSION_ID.test(value) ? document.querySelector(`#${value}`) : null;
|
|
1018
1018
|
return createTemplate(element instanceof HTMLTemplateElement ? element : value, options);
|
|
1019
1019
|
}
|
|
@@ -1023,14 +1023,14 @@ const html = ((value, options) => {
|
|
|
1023
1023
|
html.clear = () => {
|
|
1024
1024
|
templates = {};
|
|
1025
1025
|
};
|
|
1026
|
-
html.remove = (template
|
|
1027
|
-
if (typeof template
|
|
1026
|
+
html.remove = (template) => {
|
|
1027
|
+
if (typeof template !== "string" || templates[template] == null) return;
|
|
1028
1028
|
const keys = Object.keys(templates);
|
|
1029
1029
|
const { length } = keys;
|
|
1030
1030
|
const updated = {};
|
|
1031
1031
|
for (let index = 0; index < length; index += 1) {
|
|
1032
1032
|
const key = keys[index];
|
|
1033
|
-
if (key !== template
|
|
1033
|
+
if (key !== template) updated[key] = templates[key];
|
|
1034
1034
|
}
|
|
1035
1035
|
templates = updated;
|
|
1036
1036
|
};
|
package/package.json
CHANGED
|
@@ -4,19 +4,19 @@
|
|
|
4
4
|
"url": "https://oscarpalmer.se"
|
|
5
5
|
},
|
|
6
6
|
"dependencies": {
|
|
7
|
-
"@oscarpalmer/atoms": "^0.
|
|
7
|
+
"@oscarpalmer/atoms": "^0.130.0"
|
|
8
8
|
},
|
|
9
9
|
"description": "A collection of badass DOM utilities.",
|
|
10
10
|
"devDependencies": {
|
|
11
|
-
"@types/node": "^25",
|
|
11
|
+
"@types/node": "^25.1",
|
|
12
12
|
"@vitest/coverage-istanbul": "^4",
|
|
13
13
|
"jsdom": "^27.4",
|
|
14
|
-
"oxfmt": "^0.
|
|
15
|
-
"oxlint": "^1.
|
|
16
|
-
"rolldown": "1.0.0-
|
|
14
|
+
"oxfmt": "^0.27",
|
|
15
|
+
"oxlint": "^1.42",
|
|
16
|
+
"rolldown": "1.0.0-rc.2",
|
|
17
17
|
"tslib": "^2.8",
|
|
18
18
|
"typescript": "^5.9",
|
|
19
|
-
"vite": "8.0.0-beta.
|
|
19
|
+
"vite": "8.0.0-beta.11",
|
|
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.37.
|
|
96
|
+
"version": "0.37.2"
|
|
97
97
|
}
|
package/src/find/relative.ts
CHANGED
|
@@ -37,11 +37,11 @@ export function findAncestor(
|
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
if (typeof selector === 'string') {
|
|
40
|
-
if (
|
|
40
|
+
if (Element.prototype.matches.call(element, selector)) {
|
|
41
41
|
return element;
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
return
|
|
44
|
+
return Element.prototype.closest.call(element, selector);
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
if (typeof selector !== 'function') {
|