@@ -40,13 +40,18 @@ public static function parse(ParserState $parserState, ?CSSList $list = null): ?
40
40
$ comments = [];
41
41
$ result = new DeclarationBlock ($ parserState ->currentLine ());
42
42
try {
43
+ $ selectors = [];
43
44
$ selectorParts = [];
44
45
$ stringWrapperCharacter = null ;
45
- static $ stopCharacters = ['{ ' , '} ' , '\'' , '" ' ];
46
+ $ consumedNextCharacter = false ;
47
+ static $ stopCharacters = ['{ ' , '} ' , '\'' , '" ' , ', ' ];
46
48
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 );
49
53
$ nextCharacter = $ parserState ->peek ();
54
+ $ consumedNextCharacter = false ;
50
55
switch ($ nextCharacter ) {
51
56
case '\'' :
52
57
// The fallthrough is intentional.
@@ -59,9 +64,18 @@ public static function parse(ParserState $parserState, ?CSSList $list = null): ?
59
64
}
60
65
}
61
66
break ;
67
+ case ', ' :
68
+ if (!\is_string ($ stringWrapperCharacter )) {
69
+ $ selectors [] = \implode ('' , $ selectorParts );
70
+ $ selectorParts = [];
71
+ $ parserState ->consume (1 );
72
+ $ consumedNextCharacter = true ;
73
+ }
74
+ break ;
62
75
}
63
76
} 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 );
65
79
if ($ parserState ->comes ('{ ' )) {
66
80
$ parserState ->consume (1 );
67
81
}
0 commit comments