@@ -145,6 +145,10 @@ def parse_many(first, *others):
145145 'Hash[Element[div]#foobar]' ]
146146 assert parse_many ('div:not(div.foo)' ) == [
147147 '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])]' ]
148152 assert parse_many ('td ~ th' ) == [
149153 'CombinedSelector[Element[td] ~ Element[th]]' ]
150154 assert parse_many (':scope > foo' ) == [
@@ -266,6 +270,9 @@ def specificity(css):
266270 assert specificity (':not(:empty)' ) == (0 , 1 , 0 )
267271 assert specificity (':not(#foo)' ) == (1 , 0 , 0 )
268272
273+ assert specificity (':is(.foo, #bar)' ) == (1 , 0 , 0 )
274+ assert specificity (':is(:hover, :visited)' ) == (0 , 1 , 0 )
275+
269276 assert specificity ('foo:empty' ) == (0 , 1 , 1 )
270277 assert specificity ('foo:before' ) == (0 , 0 , 2 )
271278 assert specificity ('foo::before' ) == (0 , 0 , 2 )
@@ -300,6 +307,8 @@ def css2css(css, res=None):
300307 css2css (':not(*[foo])' , ':not([foo])' )
301308 css2css (':not(:empty)' )
302309 css2css (':not(#foo)' )
310+ css2css (':is(#bar, .foo)' )
311+ css2css (':is(:focused, :visited)' )
303312 css2css ('foo:empty' )
304313 css2css ('foo::before' )
305314 css2css ('foo:empty::before' )
@@ -373,6 +382,10 @@ def get_error(css):
373382 "Got pseudo-element ::before inside :not() at 12" )
374383 assert get_error (':not(:not(a))' ) == (
375384 "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>" )
376389 assert get_error (':scope > div :scope header' ) == (
377390 'Got immediate child pseudo-element ":scope" not at the start of a selector'
378391 )
@@ -863,6 +876,12 @@ def pcss(main, *selectors, **kwargs):
863876 assert pcss ('ol :Not(li[class])' ) == [
864877 'first-li' , 'second-li' , 'li-div' ,
865878 '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' ]
866885 assert pcss ('ol.a.b.c > li.c:nth-child(3)' ) == ['third-li' ]
867886
868887 # Invalid characters in XPath element names, should not crash
0 commit comments