@@ -238,12 +238,22 @@ class Negation(object):
238238 Represents selector:not(subselector)
239239 """
240240
241- def __init__ (self , selector , subselector ):
241+ def __init__ (self , selector , subselector , combinator = None , subselector2 = None ):
242242 self .selector = selector
243243 self .subselector = subselector
244+ self .combinator = combinator
245+ self .subselector2 = subselector2
244246
245247 def __repr__ (self ):
246- return "%s[%r:not(%r)]" % (self .__class__ .__name__ , self .selector , self .subselector )
248+ if self .combinator is None and self .subselector2 is None :
249+ return "%s[%r:not(%r)]" % (self .__class__ .__name__ , self .selector , self .subselector )
250+ return "%s[%r:not(%r %s %r)]" % (
251+ self .__class__ .__name__ ,
252+ self .selector ,
253+ self .subselector ,
254+ self .combinator .value ,
255+ self .subselector2 .parsed_tree ,
256+ )
247257
248258 def canonical (self ):
249259 subsel = self .subselector .canonical ()
@@ -614,9 +624,11 @@ def parse_simple_selector(stream, inside_negation=False):
614624 "Got pseudo-element ::%s inside :not() at %s"
615625 % (argument_pseudo_element , next .pos )
616626 )
627+ combinator = arguments = None
617628 if next != ("DELIM" , ")" ):
618- raise SelectorSyntaxError ("Expected ')', got %s" % (next ,))
619- result = Negation (result , argument )
629+ stream .skip_whitespace ()
630+ combinator , arguments = parse_relative_selector (stream )
631+ result = Negation (result , argument , combinator , arguments )
620632 elif ident .lower () == "has" :
621633 combinator , arguments = parse_relative_selector (stream )
622634 result = Relation (result , combinator , arguments )
0 commit comments