@@ -41,17 +41,25 @@ public static function parse(ParserState $parserState, ?CSSList $list = null): ?
4141 $ result = new DeclarationBlock ($ parserState ->currentLine ());
4242 try {
4343 $ selectorParts = [];
44+ $ stringWrapperCharacter = null ;
4445 do {
4546 $ selectorParts [] = $ parserState ->consume (1 )
4647 . $ parserState ->consumeUntil (['{ ' , '} ' , '\'' , '" ' ], false , false , $ comments );
47- if (\in_array ($ parserState ->peek (), ['\'' , '" ' ], true ) && \substr (\end ($ selectorParts ), -1 ) != '\\' ) {
48- if (!isset ($ stringWrapperCharacter )) {
49- $ stringWrapperCharacter = $ parserState ->peek ();
50- } elseif ($ stringWrapperCharacter === $ parserState ->peek ()) {
51- unset($ stringWrapperCharacter );
52- }
48+ $ nextCharacter = $ parserState ->peek ();
49+ switch ($ nextCharacter ) {
50+ case '\'' :
51+ // The fallthrough is intentional.
52+ case '" ' :
53+ if (!\is_string ($ stringWrapperCharacter )) {
54+ $ stringWrapperCharacter = $ nextCharacter ;
55+ } elseif ($ stringWrapperCharacter === $ nextCharacter ) {
56+ if (\substr (\end ($ selectorParts ), -1 ) !== '\\' ) {
57+ $ stringWrapperCharacter = null ;
58+ }
59+ }
60+ break ;
5361 }
54- } while (!\in_array ($ parserState -> peek () , ['{ ' , '} ' ], true ) || isset ($ stringWrapperCharacter ));
62+ } while (!\in_array ($ nextCharacter , ['{ ' , '} ' ], true ) || \is_string ($ stringWrapperCharacter ));
5563 $ result ->setSelectors (\implode ('' , $ selectorParts ), $ list );
5664 if ($ parserState ->comes ('{ ' )) {
5765 $ parserState ->consume (1 );
0 commit comments