@oscarpalmer/toretto 0.37.0 → 0.37.1
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 +1 -0
- package/dist/toretto.full.js +22 -21
- package/package.json +7 -7
- package/src/find/relative.ts +2 -2
package/dist/find/relative.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
function findAncestor(origin, selector) {
|
|
2
2
|
const element = getElement(origin);
|
|
3
3
|
if (element == null || selector == null) return null;
|
|
4
|
+
console.log(element);
|
|
4
5
|
if (typeof selector === "string") {
|
|
5
6
|
if (element.matches?.(selector)) return element;
|
|
6
7
|
return element.closest(selector);
|
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 {
|
|
@@ -658,6 +658,7 @@ const PROPERTY_DETAIL = "detail";
|
|
|
658
658
|
function findAncestor(origin, selector) {
|
|
659
659
|
const element = getElement(origin);
|
|
660
660
|
if (element == null || selector == null) return null;
|
|
661
|
+
console.log(element);
|
|
661
662
|
if (typeof selector === "string") {
|
|
662
663
|
if (element.matches?.(selector)) return element;
|
|
663
664
|
return element.closest(selector);
|
|
@@ -987,18 +988,18 @@ function createHtml(value) {
|
|
|
987
988
|
return parsed.body.innerHTML;
|
|
988
989
|
}
|
|
989
990
|
function createTemplate(value, options) {
|
|
990
|
-
const template
|
|
991
|
-
template
|
|
992
|
-
if (typeof value === "string" && options.cache) templates[value] = template
|
|
993
|
-
return template
|
|
991
|
+
const template = document.createElement(TEMPLATE_TAG);
|
|
992
|
+
template.innerHTML = createHtml(value);
|
|
993
|
+
if (typeof value === "string" && options.cache) templates[value] = template;
|
|
994
|
+
return template;
|
|
994
995
|
}
|
|
995
996
|
function getHtml(value) {
|
|
996
997
|
return `${TEMPORARY_ELEMENT}${typeof value === "string" ? value : value.innerHTML}${TEMPORARY_ELEMENT}`;
|
|
997
998
|
}
|
|
998
999
|
function getNodes(value, options) {
|
|
999
1000
|
if (typeof value !== "string" && !(value instanceof HTMLTemplateElement)) return [];
|
|
1000
|
-
const template
|
|
1001
|
-
return template
|
|
1001
|
+
const template = getTemplate(value, options);
|
|
1002
|
+
return template == null ? [] : [...template.content.cloneNode(true).childNodes];
|
|
1002
1003
|
}
|
|
1003
1004
|
function getOptions(input) {
|
|
1004
1005
|
const options = isPlainObject(input) ? input : {};
|
|
@@ -1012,8 +1013,8 @@ function getParser() {
|
|
|
1012
1013
|
function getTemplate(value, options) {
|
|
1013
1014
|
if (value instanceof HTMLTemplateElement) return createTemplate(value, options);
|
|
1014
1015
|
if (value.trim().length === 0) return;
|
|
1015
|
-
let template
|
|
1016
|
-
if (template
|
|
1016
|
+
let template = templates[value];
|
|
1017
|
+
if (template != null) return template;
|
|
1017
1018
|
const element = EXPRESSION_ID.test(value) ? document.querySelector(`#${value}`) : null;
|
|
1018
1019
|
return createTemplate(element instanceof HTMLTemplateElement ? element : value, options);
|
|
1019
1020
|
}
|
|
@@ -1023,14 +1024,14 @@ const html = ((value, options) => {
|
|
|
1023
1024
|
html.clear = () => {
|
|
1024
1025
|
templates = {};
|
|
1025
1026
|
};
|
|
1026
|
-
html.remove = (template
|
|
1027
|
-
if (typeof template
|
|
1027
|
+
html.remove = (template) => {
|
|
1028
|
+
if (typeof template !== "string" || templates[template] == null) return;
|
|
1028
1029
|
const keys = Object.keys(templates);
|
|
1029
1030
|
const { length } = keys;
|
|
1030
1031
|
const updated = {};
|
|
1031
1032
|
for (let index = 0; index < length; index += 1) {
|
|
1032
1033
|
const key = keys[index];
|
|
1033
|
-
if (key !== template
|
|
1034
|
+
if (key !== template) updated[key] = templates[key];
|
|
1034
1035
|
}
|
|
1035
1036
|
templates = updated;
|
|
1036
1037
|
};
|
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.1"
|
|
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') {
|