@@ -10,7 +10,7 @@ use anyhow::{bail, Context, Error};
1010use lightningcss:: {
1111 error:: ParserError ,
1212 properties:: custom:: { TokenList , TokenOrValue } ,
13- selector:: { Combinator , Component , PseudoClass , Selector } ,
13+ selector:: { Combinator , Component , PseudoClass , Selector , SelectorList } ,
1414 stylesheet:: { MinifyOptions , ParserFlags , ParserOptions , PrinterOptions , StyleSheet } ,
1515 targets:: { Browsers , Features , Targets } ,
1616 traits:: { IntoOwned , ParseWithOptions , ToCss } ,
@@ -126,7 +126,7 @@ pub fn transform_css(
126126
127127 let targets = Targets {
128128 browsers : Some ( convert_browsers ( browsers) ) ,
129- include : Features :: Nesting ,
129+ include : Features :: Nesting | Features :: IsSelector ,
130130 ..Default :: default ( )
131131 } ;
132132
@@ -574,7 +574,7 @@ impl CssNamespace {
574574/// specification), but it is popular usage, so we just add `a ` at top and
575575/// then remove it
576576fn parse_token_list < ' i > ( tokens : & TokenList < ' i > ) -> Vec < Component < ' i > > {
577- let mut buf = "a " . to_string ( ) ;
577+ let mut buf = "" . to_string ( ) ;
578578
579579 for t in tokens. 0 . iter ( ) {
580580 match t {
@@ -624,6 +624,14 @@ fn parse_token_list<'i>(tokens: &TokenList<'i>) -> Vec<Component<'i>> {
624624 debug ! ( "Parsing: {:?}" , buf)
625625 }
626626
627+ if let Ok ( s) = SelectorList :: parse_string_with_options ( & buf, Default :: default ( ) ) {
628+ if s. 0 . len ( ) != 1 {
629+ return vec ! [ Component :: Is ( s. 0 . into_owned( ) . into_boxed_slice( ) ) ] ;
630+ }
631+ }
632+
633+ buf = format ! ( "a {buf}" ) ;
634+
627635 let mut result: Vec < Component < ' i > > = vec ! [ ] ;
628636
629637 let selector = Selector :: parse_string_with_options ( & buf, Default :: default ( ) )
0 commit comments