@asamuzakjp/dom-selector 7.0.3 → 7.0.4
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/package.json +3 -3
- package/src/js/matcher.js +7 -5
- package/src/js/utility.js +9 -1
package/package.json
CHANGED
|
@@ -43,11 +43,11 @@
|
|
|
43
43
|
"eslint-plugin-regexp": "^3.1.0",
|
|
44
44
|
"eslint-plugin-unicorn": "^63.0.0",
|
|
45
45
|
"globals": "^17.4.0",
|
|
46
|
-
"jsdom": "^
|
|
46
|
+
"jsdom": "^29.0.1",
|
|
47
47
|
"mocha": "^11.7.5",
|
|
48
48
|
"neostandard": "^0.13.0",
|
|
49
49
|
"prettier": "^3.8.1",
|
|
50
|
-
"sinon": "^21.0.
|
|
50
|
+
"sinon": "^21.0.3",
|
|
51
51
|
"typescript": "^5.9.3",
|
|
52
52
|
"wpt-runner": "^6.1.0"
|
|
53
53
|
},
|
|
@@ -71,5 +71,5 @@
|
|
|
71
71
|
"engines": {
|
|
72
72
|
"node": "^20.19.0 || ^22.12.0 || >=24.0.0"
|
|
73
73
|
},
|
|
74
|
-
"version": "7.0.
|
|
74
|
+
"version": "7.0.4"
|
|
75
75
|
}
|
package/src/js/matcher.js
CHANGED
|
@@ -526,15 +526,17 @@ export const matchTypeSelector = (ast, node, opt = {}) => {
|
|
|
526
526
|
astName,
|
|
527
527
|
node
|
|
528
528
|
);
|
|
529
|
+
const isHTML =
|
|
530
|
+
node.ownerDocument.contentType === 'text/html' &&
|
|
531
|
+
(!namespaceURI || namespaceURI === 'http://www.w3.org/1999/xhtml');
|
|
532
|
+
if (isHTML && localName === astLocalName && !astName.includes('|')) {
|
|
533
|
+
return true;
|
|
534
|
+
}
|
|
529
535
|
const firstChar = localName.charCodeAt(0);
|
|
530
536
|
const isAlphabet =
|
|
531
537
|
(firstChar >= 65 && firstChar <= 90) ||
|
|
532
538
|
(firstChar >= 97 && firstChar <= 122);
|
|
533
|
-
if (
|
|
534
|
-
node.ownerDocument.contentType === 'text/html' &&
|
|
535
|
-
(!namespaceURI || namespaceURI === 'http://www.w3.org/1999/xhtml') &&
|
|
536
|
-
isAlphabet
|
|
537
|
-
) {
|
|
539
|
+
if (isHTML && isAlphabet) {
|
|
538
540
|
astPrefix = astPrefix.toLowerCase();
|
|
539
541
|
astLocalName = astLocalName.toLowerCase();
|
|
540
542
|
}
|
package/src/js/utility.js
CHANGED
|
@@ -32,6 +32,7 @@ import {
|
|
|
32
32
|
RULE,
|
|
33
33
|
SCOPE,
|
|
34
34
|
SELECTOR_LIST,
|
|
35
|
+
TAG_TYPE,
|
|
35
36
|
TARGET_ALL,
|
|
36
37
|
TARGET_FIRST,
|
|
37
38
|
TEXT_NODE,
|
|
@@ -58,7 +59,8 @@ const KEYS_NODE_FOCUSABLE_SVG = new Set([
|
|
|
58
59
|
'symbol',
|
|
59
60
|
'title'
|
|
60
61
|
]);
|
|
61
|
-
const REG_ATTR_SIMPLE = /^\[[A-Z\d-]{1,255}
|
|
62
|
+
const REG_ATTR_SIMPLE = /^\[[A-Z\d-]{1,255}(?:="?[A-Z\d\s-]{1,255}"?)?\]$/i;
|
|
63
|
+
const REG_TAG_SIMPLE = new RegExp(`^(?:${TAG_TYPE})$`);
|
|
62
64
|
const REG_EXCLUDE_BASIC =
|
|
63
65
|
/[|\\]|::|[^\u0021-\u007F\s]|\[\s*[\w$*=^|~-]+(?:(?:"[\w$*=^|~\s'-]+"|'[\w$*=^|~\s"-]+')?(?:\s+[\w$*=^|~-]+)+|"[^"\]]{1,255}|'[^'\]]{1,255})\s*\]|:(?:is|where)\(\s*\)/;
|
|
64
66
|
const REG_COMPLEX = new RegExp(`${COMPOUND_I}${COMBO}${COMPOUND_I}`, 'i');
|
|
@@ -1067,6 +1069,12 @@ export const filterSelector = (selector, target) => {
|
|
|
1067
1069
|
}
|
|
1068
1070
|
return false;
|
|
1069
1071
|
}
|
|
1072
|
+
|
|
1073
|
+
// Exclude simple tag selector for TARGET_ALL
|
|
1074
|
+
if (target === TARGET_ALL && REG_TAG_SIMPLE.test(selector)) {
|
|
1075
|
+
return false;
|
|
1076
|
+
}
|
|
1077
|
+
|
|
1070
1078
|
// Exclude various complex or unsupported selectors.
|
|
1071
1079
|
// - selectors containing '/'
|
|
1072
1080
|
// - namespaced selectors
|