@@ -40,13 +40,18 @@ public static function parse(ParserState $parserState, ?CSSList $list = null): ?
4040 $ comments = [];
4141 $ result = new DeclarationBlock ($ parserState ->currentLine ());
4242 try {
43+ $ selectors = [];
4344 $ selectorParts = [];
4445 $ stringWrapperCharacter = null ;
45- static $ stopCharacters = ['{ ' , '} ' , '\'' , '" ' ];
46+ $ consumedNextCharacter = false ;
47+ static $ stopCharacters = ['{ ' , '} ' , '\'' , '" ' , ', ' ];
4648 do {
47- $ selectorParts [] = $ parserState ->consume (1 )
48- . $ parserState ->consumeUntil ($ stopCharacters , false , false , $ comments );
49+ if (!$ consumedNextCharacter ) {
50+ $ selectorParts [] = $ parserState ->consume (1 );
51+ }
52+ $ selectorParts [] = $ parserState ->consumeUntil ($ stopCharacters , false , false , $ comments );
4953 $ nextCharacter = $ parserState ->peek ();
54+ $ consumedNextCharacter = false ;
5055 switch ($ nextCharacter ) {
5156 case '\'' :
5257 // The fallthrough is intentional.
@@ -59,9 +64,18 @@ public static function parse(ParserState $parserState, ?CSSList $list = null): ?
5964 }
6065 }
6166 break ;
67+ case ', ' :
68+ if (!\is_string ($ stringWrapperCharacter )) {
69+ $ selectors [] = \implode ('' , $ selectorParts );
70+ $ selectorParts = [];
71+ $ parserState ->consume (1 );
72+ $ consumedNextCharacter = true ;
73+ }
74+ break ;
6275 }
6376 } while (!\in_array ($ nextCharacter , ['{ ' , '} ' ], true ) || \is_string ($ stringWrapperCharacter ));
64- $ result ->setSelectors (\implode ('' , $ selectorParts ), $ list );
77+ $ selectors [] = \implode ('' , $ selectorParts ); // add final or only selector
78+ $ result ->setSelectors ($ selectors , $ list );
6579 if ($ parserState ->comes ('{ ' )) {
6680 $ parserState ->consume (1 );
6781 }
0 commit comments