@asamuzakjp/dom-selector 0.15.10 → 0.15.12
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 +24 -11
package/package.json
CHANGED
package/src/js/matcher.js
CHANGED
|
@@ -100,7 +100,7 @@ const isAttached = (node = {}) => {
|
|
|
100
100
|
const root = ownerDocument.documentElement;
|
|
101
101
|
if (node === root) {
|
|
102
102
|
res = true;
|
|
103
|
-
} else {
|
|
103
|
+
} else if (root) {
|
|
104
104
|
const posBit =
|
|
105
105
|
node.compareDocumentPosition(root) & DOCUMENT_POSITION_CONTAINS;
|
|
106
106
|
res = posBit;
|
|
@@ -1761,17 +1761,30 @@ class Matcher {
|
|
|
1761
1761
|
const [{ nodes }] = twig;
|
|
1762
1762
|
matched.push(...nodes);
|
|
1763
1763
|
} else if (l > 1) {
|
|
1764
|
-
const
|
|
1764
|
+
const prevItem = twig[0];
|
|
1765
|
+
let j = 1;
|
|
1766
|
+
while (j < l) {
|
|
1765
1767
|
const { combo: prevCombo, nodes: prevNodes } = prevItem;
|
|
1766
|
-
const { combo: nextCombo, nodes: nextNodes } =
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1768
|
+
const { combo: nextCombo, nodes: nextNodes } = twig[j];
|
|
1769
|
+
if (prevCombo && prevNodes.size && nextNodes.size) {
|
|
1770
|
+
const nodes =
|
|
1771
|
+
matchCombinator(prevCombo, [...prevNodes], [...nextNodes]);
|
|
1772
|
+
if (nodes.length) {
|
|
1773
|
+
if (j === l - 1) {
|
|
1774
|
+
matched.push(...new Set(nodes));
|
|
1775
|
+
break;
|
|
1776
|
+
} else {
|
|
1777
|
+
prevItem.combo = nextCombo;
|
|
1778
|
+
prevItem.nodes = new Set(nodes);
|
|
1779
|
+
}
|
|
1780
|
+
} else {
|
|
1781
|
+
break;
|
|
1782
|
+
}
|
|
1783
|
+
} else {
|
|
1784
|
+
break;
|
|
1785
|
+
}
|
|
1786
|
+
j++;
|
|
1787
|
+
}
|
|
1775
1788
|
}
|
|
1776
1789
|
}
|
|
1777
1790
|
return matched;
|