@asamuzakjp/dom-selector 0.12.3 → 0.12.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 +1 -1
- package/src/js/matcher.js +11 -10
package/package.json
CHANGED
package/src/js/matcher.js
CHANGED
|
@@ -19,6 +19,10 @@ const FILTER_ACCEPT = 1;
|
|
|
19
19
|
const FILTER_REJECT = 2;
|
|
20
20
|
const FILTER_SHOW_ELEMENT = 1;
|
|
21
21
|
const TEXT_NODE = 3;
|
|
22
|
+
const UNIVERSAL_SELECTOR = {
|
|
23
|
+
name: '*',
|
|
24
|
+
type: TYPE_SELECTOR
|
|
25
|
+
};
|
|
22
26
|
|
|
23
27
|
/* regexp */
|
|
24
28
|
const HEX_CAPTURE = /^([\da-f]{1,6}\s?)/i;
|
|
@@ -955,7 +959,7 @@ const matchPseudoClassSelector = (
|
|
|
955
959
|
break;
|
|
956
960
|
case 'valid':
|
|
957
961
|
if (HTML_FORM_INPUT.test(localName) ||
|
|
958
|
-
/^(?:f(?:ieldset|orm)|button
|
|
962
|
+
/^(?:f(?:ieldset|orm)|button)$/.test(localName)) {
|
|
959
963
|
if (node.checkValidity()) {
|
|
960
964
|
matched.push(node);
|
|
961
965
|
}
|
|
@@ -963,7 +967,7 @@ const matchPseudoClassSelector = (
|
|
|
963
967
|
break;
|
|
964
968
|
case 'invalid':
|
|
965
969
|
if (HTML_FORM_INPUT.test(localName) ||
|
|
966
|
-
/^(?:f(?:ieldset|orm)|button
|
|
970
|
+
/^(?:f(?:ieldset|orm)|button)$/.test(localName)) {
|
|
967
971
|
if (!node.checkValidity()) {
|
|
968
972
|
matched.push(node);
|
|
969
973
|
}
|
|
@@ -1457,10 +1461,7 @@ class Matcher {
|
|
|
1457
1461
|
if (firstChild.type === PSEUDO_CLASS_SELECTOR &&
|
|
1458
1462
|
PSEUDO_FUNC.test(unescapeSelector(firstChild.name)) &&
|
|
1459
1463
|
node.nodeType === ELEMENT_NODE) {
|
|
1460
|
-
const iteratorLeaf =
|
|
1461
|
-
name: '*',
|
|
1462
|
-
type: TYPE_SELECTOR
|
|
1463
|
-
};
|
|
1464
|
+
const iteratorLeaf = UNIVERSAL_SELECTOR;
|
|
1464
1465
|
const iterator = this._createIterator(iteratorLeaf, node);
|
|
1465
1466
|
let nextNode = iterator.nextNode();
|
|
1466
1467
|
while (nextNode) {
|
|
@@ -1475,10 +1476,7 @@ class Matcher {
|
|
|
1475
1476
|
if (firstChild.type === COMBINATOR ||
|
|
1476
1477
|
(firstChild.type === PSEUDO_CLASS_SELECTOR &&
|
|
1477
1478
|
PSEUDO_NTH.test(unescapeSelector(firstChild.name)))) {
|
|
1478
|
-
iteratorLeaf =
|
|
1479
|
-
name: '*',
|
|
1480
|
-
type: TYPE_SELECTOR
|
|
1481
|
-
};
|
|
1479
|
+
iteratorLeaf = UNIVERSAL_SELECTOR;
|
|
1482
1480
|
} else {
|
|
1483
1481
|
iteratorLeaf = children.shift();
|
|
1484
1482
|
}
|
|
@@ -1536,6 +1534,9 @@ class Matcher {
|
|
|
1536
1534
|
leaves.push(items.shift());
|
|
1537
1535
|
}
|
|
1538
1536
|
}
|
|
1537
|
+
if (leaves.length === 1) {
|
|
1538
|
+
leaves.push(UNIVERSAL_SELECTOR);
|
|
1539
|
+
}
|
|
1539
1540
|
const arr = this._matchCombinator(leaves, nextNode);
|
|
1540
1541
|
if (!arr.length || arr.length === 1) {
|
|
1541
1542
|
[nextNode] = arr;
|