@asamuzakjp/dom-selector 0.6.0 → 0.6.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 CHANGED
@@ -40,5 +40,5 @@
40
40
  "test": "c8 --reporter=text mocha --exit test/**/*.test.js",
41
41
  "tsc": "npx tsc"
42
42
  },
43
- "version": "0.6.0"
43
+ "version": "0.6.2"
44
44
  }
package/src/js/matcher.js CHANGED
@@ -1337,15 +1337,13 @@ class Matcher {
1337
1337
  */
1338
1338
  querySelector() {
1339
1339
  const arr = this._match(this.#ast, this.#node);
1340
- let res;
1341
1340
  if (arr.length) {
1342
- const [i, j] = arr;
1343
- if (i !== this.#node) {
1344
- res = i;
1345
- } else if (j) {
1346
- res = j;
1341
+ const i = arr.findIndex(node => node === this.#node);
1342
+ if (i >= 0) {
1343
+ arr.splice(i, 1);
1347
1344
  }
1348
1345
  }
1346
+ const [res] = arr;
1349
1347
  return res || null;
1350
1348
  }
1351
1349