diff --git a/src/visitor.py b/src/visitor.py index dbd965d..a32c8e1 100644 --- a/src/visitor.py +++ b/src/visitor.py @@ -111,7 +111,14 @@ def visit_not_pseudo_class_selector( context = (subnode for node in context for subnode in walk_nodes(node)) for node in context: - if any(visit(selector.not_selector, [node], recurse=False)): + root = node + while True: + if root.parent is None: + break + root = root.parent + + root_not_matches = visit(selector.not_selector, [root], recurse=True) + if node in root_not_matches: continue # exclude this node (not condition matched) yield node