@asamuzakjp/dom-selector 0.12.6 → 0.12.7
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 +4 -4
package/package.json
CHANGED
package/src/js/matcher.js
CHANGED
|
@@ -1018,17 +1018,17 @@ const matchPseudoClassSelector = (
|
|
|
1018
1018
|
}
|
|
1019
1019
|
break;
|
|
1020
1020
|
case 'first-child':
|
|
1021
|
-
if (node === parentNode.firstElementChild) {
|
|
1021
|
+
if (parentNode && node === parentNode.firstElementChild) {
|
|
1022
1022
|
matched.push(node);
|
|
1023
1023
|
}
|
|
1024
1024
|
break;
|
|
1025
1025
|
case 'last-child':
|
|
1026
|
-
if (node === parentNode.lastElementChild) {
|
|
1026
|
+
if (parentNode && node === parentNode.lastElementChild) {
|
|
1027
1027
|
matched.push(node);
|
|
1028
1028
|
}
|
|
1029
1029
|
break;
|
|
1030
1030
|
case 'only-child':
|
|
1031
|
-
if (node === parentNode.firstElementChild &&
|
|
1031
|
+
if (parentNode && node === parentNode.firstElementChild &&
|
|
1032
1032
|
node === parentNode.lastElementChild) {
|
|
1033
1033
|
matched.push(node);
|
|
1034
1034
|
}
|
|
@@ -1261,7 +1261,7 @@ class Matcher {
|
|
|
1261
1261
|
if (items.length) {
|
|
1262
1262
|
const [firstItem] = items;
|
|
1263
1263
|
let rootNode = prevNode;
|
|
1264
|
-
if (comboName === '+' || comboName === '~') {
|
|
1264
|
+
if ((comboName === '+' || comboName === '~') && rootNode.parentNode) {
|
|
1265
1265
|
rootNode = rootNode.parentNode;
|
|
1266
1266
|
}
|
|
1267
1267
|
const iterator = this._createIterator(firstItem, rootNode);
|