@asamuzakjp/dom-selector 0.13.2 → 0.13.5
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 +2 -2
- package/src/js/matcher.js +4 -4
package/package.json
CHANGED
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"chai": "^4.3.7",
|
|
29
29
|
"eslint": "^8.41.0",
|
|
30
30
|
"eslint-config-standard": "^17.0.0",
|
|
31
|
-
"eslint-plugin-jsdoc": "^44.2.
|
|
31
|
+
"eslint-plugin-jsdoc": "^44.2.7",
|
|
32
32
|
"eslint-plugin-regexp": "^1.15.0",
|
|
33
33
|
"eslint-plugin-unicorn": "^47.0.0",
|
|
34
34
|
"jsdom": "^22.0.0",
|
|
@@ -42,5 +42,5 @@
|
|
|
42
42
|
"test": "c8 --reporter=text mocha --exit test/**/*.test.js",
|
|
43
43
|
"tsc": "npx tsc"
|
|
44
44
|
},
|
|
45
|
-
"version": "0.13.
|
|
45
|
+
"version": "0.13.5"
|
|
46
46
|
}
|
package/src/js/matcher.js
CHANGED
|
@@ -209,7 +209,7 @@ const groupASTLeaves = (branch = []) => {
|
|
|
209
209
|
*/
|
|
210
210
|
const collectNthChild = (anb = {}, node = {}) => {
|
|
211
211
|
const { a, b, reverse, selector } = anb;
|
|
212
|
-
const { nodeType,
|
|
212
|
+
const { nodeType, parentNode } = node;
|
|
213
213
|
const matched = [];
|
|
214
214
|
if (Number.isInteger(a) && Number.isInteger(b) && nodeType === ELEMENT_NODE) {
|
|
215
215
|
const arr = [...parentNode.children];
|
|
@@ -219,7 +219,7 @@ const collectNthChild = (anb = {}, node = {}) => {
|
|
|
219
219
|
const l = arr.length;
|
|
220
220
|
const items = [];
|
|
221
221
|
if (selector) {
|
|
222
|
-
const ar = new Matcher(selector,
|
|
222
|
+
const ar = new Matcher(selector, parentNode).querySelectorAll();
|
|
223
223
|
if (ar.length) {
|
|
224
224
|
items.push(...ar);
|
|
225
225
|
}
|
|
@@ -372,8 +372,8 @@ const matchAnPlusB = (nthName, ast = {}, node = {}) => {
|
|
|
372
372
|
type: astType
|
|
373
373
|
} = ast;
|
|
374
374
|
const identName = unescapeSelector(nthIdentName);
|
|
375
|
-
const { nodeType } = node;
|
|
376
|
-
if (astType === NTH && nodeType === ELEMENT_NODE) {
|
|
375
|
+
const { nodeType, parentNode } = node;
|
|
376
|
+
if (astType === NTH && nodeType === ELEMENT_NODE && parentNode) {
|
|
377
377
|
const anbMap = new Map();
|
|
378
378
|
if (identName) {
|
|
379
379
|
if (identName === 'even') {
|