@@ -145,6 +145,10 @@ def parse_many(first, *others):
145
145
'Hash[Element[div]#foobar]' ]
146
146
assert parse_many ('div:not(div.foo)' ) == [
147
147
'Negation[Element[div]:not(Class[Element[div].foo])]' ]
148
+ assert parse_many ('div:is(.foo, #bar)' ) == [
149
+ 'Matching[Element[div]:is(Class[Element[*].foo], Hash[Element[*]#bar])]' ]
150
+ assert parse_many (':is(:hover, :visited)' ) == [
151
+ 'Matching[Element[*]:is(Pseudo[Element[*]:hover], Pseudo[Element[*]:visited])]' ]
148
152
assert parse_many ('td ~ th' ) == [
149
153
'CombinedSelector[Element[td] ~ Element[th]]' ]
150
154
assert parse_many (':scope > foo' ) == [
@@ -266,6 +270,9 @@ def specificity(css):
266
270
assert specificity (':not(:empty)' ) == (0 , 1 , 0 )
267
271
assert specificity (':not(#foo)' ) == (1 , 0 , 0 )
268
272
273
+ assert specificity (':is(.foo, #bar)' ) == (1 , 0 , 0 )
274
+ assert specificity (':is(:hover, :visited)' ) == (0 , 1 , 0 )
275
+
269
276
assert specificity ('foo:empty' ) == (0 , 1 , 1 )
270
277
assert specificity ('foo:before' ) == (0 , 0 , 2 )
271
278
assert specificity ('foo::before' ) == (0 , 0 , 2 )
@@ -300,6 +307,8 @@ def css2css(css, res=None):
300
307
css2css (':not(*[foo])' , ':not([foo])' )
301
308
css2css (':not(:empty)' )
302
309
css2css (':not(#foo)' )
310
+ css2css (':is(#bar, .foo)' )
311
+ css2css (':is(:focused, :visited)' )
303
312
css2css ('foo:empty' )
304
313
css2css ('foo::before' )
305
314
css2css ('foo:empty::before' )
@@ -373,6 +382,10 @@ def get_error(css):
373
382
"Got pseudo-element ::before inside :not() at 12" )
374
383
assert get_error (':not(:not(a))' ) == (
375
384
"Got nested :not()" )
385
+ assert get_error (':is(:before)' ) == (
386
+ "Got pseudo-element ::before inside function" )
387
+ assert get_error (':is(a b)' ) == (
388
+ "Expected an argument, got <IDENT 'b' at 6>" )
376
389
assert get_error (':scope > div :scope header' ) == (
377
390
'Got immediate child pseudo-element ":scope" not at the start of a selector'
378
391
)
@@ -863,6 +876,12 @@ def pcss(main, *selectors, **kwargs):
863
876
assert pcss ('ol :Not(li[class])' ) == [
864
877
'first-li' , 'second-li' , 'li-div' ,
865
878
'fifth-li' , 'sixth-li' , 'seventh-li' ]
879
+ assert pcss (':is(#first-li, #second-li)' ) == [
880
+ 'first-li' , 'second-li' ]
881
+ assert pcss ('a:is(#name-anchor, #tag-anchor)' ) == [
882
+ 'name-anchor' , 'tag-anchor' ]
883
+ assert pcss (':is(.c)' ) == [
884
+ 'first-ol' , 'third-li' , 'fourth-li' ]
866
885
assert pcss ('ol.a.b.c > li.c:nth-child(3)' ) == ['third-li' ]
867
886
868
887
# Invalid characters in XPath element names, should not crash
0 commit comments