@@ -69,11 +69,9 @@ public static function parseList(ParserState $oParserState, CSSList $oList)
6969 $ oParserState = new ParserState ($ oParserState , Settings::create ());
7070 }
7171 $ bLenientParsing = $ oParserState ->getSettings ()->bLenientParsing ;
72- $ comments = [];
72+ $ aComments = [];
7373 while (!$ oParserState ->isEnd ()) {
74- if (empty ($ comments )) {
75- $ comments = $ oParserState ->consumeWhiteSpace ();
76- }
74+ $ aComments = array_merge ($ aComments , $ oParserState ->consumeWhiteSpace ());
7775 $ oListItem = null ;
7876 if ($ bLenientParsing ) {
7977 try {
@@ -89,11 +87,12 @@ public static function parseList(ParserState $oParserState, CSSList $oList)
8987 return ;
9088 }
9189 if ($ oListItem ) {
92- $ oListItem ->setComments ( $ comments );
90+ $ oListItem ->addComments ( $ aComments );
9391 $ oList ->append ($ oListItem );
9492 }
95- $ comments = $ oParserState ->consumeWhiteSpace ();
93+ $ aComments = $ oParserState ->consumeWhiteSpace ();
9694 }
95+ $ oList ->addComments ($ aComments );
9796 if (!$ bIsRoot && !$ bLenientParsing ) {
9897 throw new SourceException ("Unexpected end of document " , $ oParserState ->currentLine ());
9998 }
@@ -175,10 +174,10 @@ private static function parseAtRule(ParserState $oParserState)
175174 $ oParserState ->consumeUntil (['; ' , ParserState::EOF ], true , true );
176175 return new Import ($ oLocation , $ sMediaQuery ?: null , $ iIdentifierLineNum );
177176 } elseif ($ sIdentifier === 'charset ' ) {
178- $ sCharset = CSSString::parse ($ oParserState );
177+ $ oCharsetString = CSSString::parse ($ oParserState );
179178 $ oParserState ->consumeWhiteSpace ();
180179 $ oParserState ->consumeUntil (['; ' , ParserState::EOF ], true , true );
181- return new Charset ($ sCharset , $ iIdentifierLineNum );
180+ return new Charset ($ oCharsetString , $ iIdentifierLineNum );
182181 } elseif (self ::identifierIs ($ sIdentifier , 'keyframes ' )) {
183182 $ oResult = new KeyFrame ($ iIdentifierLineNum );
184183 $ oResult ->setVendorKeyFrame ($ sIdentifier );
@@ -405,7 +404,7 @@ public function __toString()
405404 /**
406405 * @return string
407406 */
408- public function render (OutputFormat $ oOutputFormat )
407+ protected function renderListContents (OutputFormat $ oOutputFormat )
409408 {
410409 $ sResult = '' ;
411410 $ bIsFirst = true ;
@@ -415,18 +414,7 @@ public function render(OutputFormat $oOutputFormat)
415414 }
416415 foreach ($ this ->aContents as $ oContent ) {
417416 $ sRendered = $ oOutputFormat ->safely (function () use ($ oNextLevel , $ oContent ) {
418- $ sResult = '' ;
419- $ aComments = $ oContent ->getComments ();
420- $ c = count ($ aComments );
421-
422- foreach ($ aComments as $ i => $ oComment ) {
423- $ sResult .= $ oComment ->render ($ oNextLevel );
424- $ sResult .= $ oNextLevel ->spaceAfterBlocks ();
425- if ($ c - 1 !== $ i ) {
426- $ sResult .= $ oNextLevel ->spaceAfterBlocks ();
427- }
428- }
429- return $ sResult . $ oContent ->render ($ oNextLevel );
417+ return $ oContent ->render ($ oNextLevel );
430418 });
431419 if ($ sRendered === null ) {
432420 continue ;
0 commit comments