* Checks if the selector is using grandchild selector semantics * `node.querySelector('child grandchild')` or `'child>grandchild'` But, * specifically allow multi-selectors `'div, span'`. * @param {string} selector * @return {boolean}
(selector)
| 205 | * @return {boolean} |
| 206 | */ |
| 207 | function selectorNeedsScope(selector) { |
| 208 | // strip out things that can't affect children selection |
| 209 | selector = selector.replace(/\(.*\)|\[.*\]/, function (match) { |
| 210 | return match[0] + match[match.length - 1]; |
| 211 | }); |
| 212 | |
| 213 | // This regex actually verifies there is no whitespace (implicit child |
| 214 | // semantics) or `>` chars (direct child semantics). The one exception is |
| 215 | // for `,` multi-selectors, which can have whitespace. |
| 216 | const noChildSemantics = /^(\s*,\s*|(?!\s|>).)*$/.test(selector); |
| 217 | return !noChildSemantics; |
| 218 | } |
| 219 | |
| 220 | return { |
| 221 | CallExpression(node) { |
no test coverage detected