@asamuzakjp/dom-selector 7.0.1 → 7.0.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/package.json +6 -7
- package/src/index.js +8 -17
- package/src/js/finder.js +0 -1
- package/src/js/matcher.js +4 -4
- package/src/js/parser.js +1 -2
package/package.json
CHANGED
|
@@ -23,11 +23,10 @@
|
|
|
23
23
|
},
|
|
24
24
|
"./package.json": "./package.json"
|
|
25
25
|
},
|
|
26
|
-
"types": "types/index.d.ts",
|
|
27
26
|
"dependencies": {
|
|
28
27
|
"@asamuzakjp/nwsapi": "^2.3.9",
|
|
29
28
|
"bidi-js": "^1.0.3",
|
|
30
|
-
"css-tree": "^3.1
|
|
29
|
+
"css-tree": "^3.2.1",
|
|
31
30
|
"is-potential-custom-element-name": "^1.0.1",
|
|
32
31
|
"lru-cache": "^11.2.6"
|
|
33
32
|
},
|
|
@@ -37,18 +36,18 @@
|
|
|
37
36
|
"c8": "^11.0.0",
|
|
38
37
|
"chai": "^6.2.2",
|
|
39
38
|
"commander": "^14.0.3",
|
|
40
|
-
"eslint": "^9.39.
|
|
39
|
+
"eslint": "^9.39.4",
|
|
41
40
|
"eslint-config-prettier": "^10.1.8",
|
|
42
|
-
"eslint-plugin-jsdoc": "^62.
|
|
41
|
+
"eslint-plugin-jsdoc": "^62.8.0",
|
|
43
42
|
"eslint-plugin-prettier": "^5.5.5",
|
|
44
|
-
"eslint-plugin-regexp": "^3.
|
|
43
|
+
"eslint-plugin-regexp": "^3.1.0",
|
|
45
44
|
"eslint-plugin-unicorn": "^63.0.0",
|
|
46
45
|
"globals": "^17.4.0",
|
|
47
46
|
"jsdom": "^28.1.0",
|
|
48
47
|
"mocha": "^11.7.5",
|
|
49
48
|
"neostandard": "^0.13.0",
|
|
50
49
|
"prettier": "^3.8.1",
|
|
51
|
-
"sinon": "^21.0.
|
|
50
|
+
"sinon": "^21.0.2",
|
|
52
51
|
"typescript": "^5.9.3",
|
|
53
52
|
"wpt-runner": "^6.1.0"
|
|
54
53
|
},
|
|
@@ -72,5 +71,5 @@
|
|
|
72
71
|
"engines": {
|
|
73
72
|
"node": "^20.19.0 || ^22.12.0 || >=24.0.0"
|
|
74
73
|
},
|
|
75
|
-
"version": "7.0.
|
|
74
|
+
"version": "7.0.2"
|
|
76
75
|
}
|
package/src/index.js
CHANGED
|
@@ -125,9 +125,7 @@ export class DOMSelector {
|
|
|
125
125
|
opt.check = true;
|
|
126
126
|
opt.noexcept = true;
|
|
127
127
|
opt.warn = false;
|
|
128
|
-
this.#finder.setup(selector, node, opt);
|
|
129
|
-
const res = this.#finder.find(TARGET_SELF);
|
|
130
|
-
return res;
|
|
128
|
+
return this.#finder.setup(selector, node, opt).find(TARGET_SELF);
|
|
131
129
|
};
|
|
132
130
|
|
|
133
131
|
/**
|
|
@@ -163,8 +161,7 @@ export class DOMSelector {
|
|
|
163
161
|
if (filterMatches) {
|
|
164
162
|
try {
|
|
165
163
|
const n = this.#idlUtils ? this.#idlUtils.wrapperForImpl(node) : node;
|
|
166
|
-
|
|
167
|
-
return res;
|
|
164
|
+
return this.#nwsapi.match(selector, n);
|
|
168
165
|
} catch (e) {
|
|
169
166
|
// fall through
|
|
170
167
|
}
|
|
@@ -175,8 +172,7 @@ export class DOMSelector {
|
|
|
175
172
|
if (this.#idlUtils) {
|
|
176
173
|
node = this.#idlUtils.wrapperForImpl(node);
|
|
177
174
|
}
|
|
178
|
-
this.#finder.setup(selector, node, opt);
|
|
179
|
-
const nodes = this.#finder.find(TARGET_SELF);
|
|
175
|
+
const nodes = this.#finder.setup(selector, node, opt).find(TARGET_SELF);
|
|
180
176
|
res = nodes.size;
|
|
181
177
|
} catch (e) {
|
|
182
178
|
this.#finder.onError(e, opt);
|
|
@@ -217,8 +213,7 @@ export class DOMSelector {
|
|
|
217
213
|
if (filterMatches) {
|
|
218
214
|
try {
|
|
219
215
|
const n = this.#idlUtils ? this.#idlUtils.wrapperForImpl(node) : node;
|
|
220
|
-
|
|
221
|
-
return res;
|
|
216
|
+
return this.#nwsapi.closest(selector, n);
|
|
222
217
|
} catch (e) {
|
|
223
218
|
// fall through
|
|
224
219
|
}
|
|
@@ -229,8 +224,7 @@ export class DOMSelector {
|
|
|
229
224
|
if (this.#idlUtils) {
|
|
230
225
|
node = this.#idlUtils.wrapperForImpl(node);
|
|
231
226
|
}
|
|
232
|
-
this.#finder.setup(selector, node, opt);
|
|
233
|
-
const nodes = this.#finder.find(TARGET_LINEAL);
|
|
227
|
+
const nodes = this.#finder.setup(selector, node, opt).find(TARGET_LINEAL);
|
|
234
228
|
if (nodes.size) {
|
|
235
229
|
let refNode = node;
|
|
236
230
|
while (refNode) {
|
|
@@ -264,8 +258,7 @@ export class DOMSelector {
|
|
|
264
258
|
if (this.#idlUtils) {
|
|
265
259
|
node = this.#idlUtils.wrapperForImpl(node);
|
|
266
260
|
}
|
|
267
|
-
this.#finder.setup(selector, node, opt);
|
|
268
|
-
const nodes = this.#finder.find(TARGET_FIRST);
|
|
261
|
+
const nodes = this.#finder.setup(selector, node, opt).find(TARGET_FIRST);
|
|
269
262
|
if (nodes.size) {
|
|
270
263
|
[res] = [...nodes];
|
|
271
264
|
}
|
|
@@ -307,8 +300,7 @@ export class DOMSelector {
|
|
|
307
300
|
if (filterMatches) {
|
|
308
301
|
try {
|
|
309
302
|
const n = this.#idlUtils ? this.#idlUtils.wrapperForImpl(node) : node;
|
|
310
|
-
|
|
311
|
-
return res;
|
|
303
|
+
return this.#nwsapi.select(selector, n);
|
|
312
304
|
} catch (e) {
|
|
313
305
|
// fall through
|
|
314
306
|
}
|
|
@@ -319,8 +311,7 @@ export class DOMSelector {
|
|
|
319
311
|
if (this.#idlUtils) {
|
|
320
312
|
node = this.#idlUtils.wrapperForImpl(node);
|
|
321
313
|
}
|
|
322
|
-
this.#finder.setup(selector, node, opt);
|
|
323
|
-
const nodes = this.#finder.find(TARGET_ALL);
|
|
314
|
+
const nodes = this.#finder.setup(selector, node, opt).find(TARGET_ALL);
|
|
324
315
|
if (nodes.size) {
|
|
325
316
|
res = [...nodes];
|
|
326
317
|
}
|
package/src/js/finder.js
CHANGED
package/src/js/matcher.js
CHANGED
|
@@ -427,15 +427,15 @@ export const matchAttributeSelector = (ast, node, opt = {}) => {
|
|
|
427
427
|
let attrValue;
|
|
428
428
|
if (astIdentValue) {
|
|
429
429
|
if (caseInsensitive) {
|
|
430
|
-
attrValue = astIdentValue.toLowerCase();
|
|
430
|
+
attrValue = astIdentValue.toLowerCase().replace(/\\(?!\\)/g, '');
|
|
431
431
|
} else {
|
|
432
|
-
attrValue = astIdentValue;
|
|
432
|
+
attrValue = astIdentValue.replace(/\\(?!\\)/g, '');
|
|
433
433
|
}
|
|
434
434
|
} else if (astStringValue) {
|
|
435
435
|
if (caseInsensitive) {
|
|
436
|
-
attrValue = astStringValue.toLowerCase();
|
|
436
|
+
attrValue = astStringValue.toLowerCase().replace(/\\(?!\\)/g, '');
|
|
437
437
|
} else {
|
|
438
|
-
attrValue = astStringValue;
|
|
438
|
+
attrValue = astStringValue.replace(/\\(?!\\)/g, '');
|
|
439
439
|
}
|
|
440
440
|
} else if (astStringValue === '') {
|
|
441
441
|
attrValue = astStringValue;
|
package/src/js/parser.js
CHANGED