Fix complex matching, don't always add the node to left, and fix ' '.
Showing
1 changed file
with
0 additions
and
7 deletions
| ... | @@ -171,16 +171,9 @@ const compileMatcher = (ast: AST, selector: string): MatcherProducer => { | ... | @@ -171,16 +171,9 @@ const compileMatcher = (ast: AST, selector: string): MatcherProducer => { |
| 171 | leftMatches.add(node) | 171 | leftMatches.add(node) |
| 172 | } | 172 | } |
| 173 | if (!rightMatcher(context, node, parent, i, debug)) return false | 173 | if (!rightMatcher(context, node, parent, i, debug)) return false |
| 174 | leftMatches.add(node) | ||
| 175 | if (debug) console.log('matched on right', { left, right, combinator, pos, node, parent }) | 174 | if (debug) console.log('matched on right', { left, right, combinator, pos, node, parent }) |
| 176 | switch (combinator) { | 175 | switch (combinator) { |
| 177 | case ' ': | 176 | case ' ': |
| 178 | let parentPtr = parent | ||
| 179 | while (parentPtr) { | ||
| 180 | if (leftMatches.has(parentPtr)) return true | ||
| 181 | parentPtr = parentPtr.parent | ||
| 182 | } | ||
| 183 | return false | ||
| 184 | case '>': | 177 | case '>': |
| 185 | if (debug) console.log('leftMatches parent', leftMatches.has(parent)) | 178 | if (debug) console.log('leftMatches parent', leftMatches.has(parent)) |
| 186 | return parent ? leftMatches.has(parent) : false | 179 | return parent ? leftMatches.has(parent) : false | ... | ... |
-
Please register or sign in to post a comment