@asamuzakjp/dom-selector 0.15.9 → 0.15.10
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 +1 -1
- package/src/js/matcher.js +30 -5
package/package.json
CHANGED
package/src/js/matcher.js
CHANGED
|
@@ -1099,7 +1099,8 @@ const matchPseudoClassSelector = (
|
|
|
1099
1099
|
break;
|
|
1100
1100
|
}
|
|
1101
1101
|
case 'target': {
|
|
1102
|
-
if (
|
|
1102
|
+
if (isAttached(node) && docURL.hash &&
|
|
1103
|
+
node.id && docURL.hash === `#${node.id}`) {
|
|
1103
1104
|
matched.push(node);
|
|
1104
1105
|
}
|
|
1105
1106
|
break;
|
|
@@ -1864,9 +1865,21 @@ class Matcher {
|
|
|
1864
1865
|
querySelector() {
|
|
1865
1866
|
let res;
|
|
1866
1867
|
try {
|
|
1867
|
-
|
|
1868
|
+
let node;
|
|
1869
|
+
if (isAttached(this.#node)) {
|
|
1870
|
+
node = this.#document;
|
|
1871
|
+
} else {
|
|
1872
|
+
node = this.#node;
|
|
1873
|
+
while (node) {
|
|
1874
|
+
if (!node.parentNode) {
|
|
1875
|
+
break;
|
|
1876
|
+
}
|
|
1877
|
+
node = node.parentNode;
|
|
1878
|
+
}
|
|
1879
|
+
}
|
|
1880
|
+
const arr = this._find(this.#ast, node);
|
|
1868
1881
|
if (arr.length) {
|
|
1869
|
-
const i = arr.findIndex(
|
|
1882
|
+
const i = arr.findIndex(n => n === this.#node);
|
|
1870
1883
|
if (i >= 0) {
|
|
1871
1884
|
arr.splice(i, 1);
|
|
1872
1885
|
}
|
|
@@ -1902,9 +1915,21 @@ class Matcher {
|
|
|
1902
1915
|
querySelectorAll() {
|
|
1903
1916
|
const res = [];
|
|
1904
1917
|
try {
|
|
1905
|
-
|
|
1918
|
+
let node;
|
|
1919
|
+
if (isAttached(this.#node)) {
|
|
1920
|
+
node = this.#document;
|
|
1921
|
+
} else {
|
|
1922
|
+
node = this.#node;
|
|
1923
|
+
while (node) {
|
|
1924
|
+
if (!node.parentNode) {
|
|
1925
|
+
break;
|
|
1926
|
+
}
|
|
1927
|
+
node = node.parentNode;
|
|
1928
|
+
}
|
|
1929
|
+
}
|
|
1930
|
+
const arr = this._find(this.#ast, node);
|
|
1906
1931
|
if (arr.length) {
|
|
1907
|
-
const i = arr.findIndex(
|
|
1932
|
+
const i = arr.findIndex(n => n === this.#node);
|
|
1908
1933
|
if (i >= 0) {
|
|
1909
1934
|
arr.splice(i, 1);
|
|
1910
1935
|
}
|