diff --git a/lib/Sabberworm/CSS/CSSList/CSSList.php b/lib/Sabberworm/CSS/CSSList/CSSList.php index 5def89a0..6acfa375 100644 --- a/lib/Sabberworm/CSS/CSSList/CSSList.php +++ b/lib/Sabberworm/CSS/CSSList/CSSList.php @@ -61,7 +61,6 @@ public static function parseList(ParserState $oParserState, CSSList $oList) { $oListItem->setComments($comments); $oList->append($oListItem); } - $oParserState->consumeWhiteSpace(); } if(!$bIsRoot && !$bLenientParsing) { throw new SourceException("Unexpected end of document", $oParserState->currentLine()); diff --git a/lib/Sabberworm/CSS/Rule/Rule.php b/lib/Sabberworm/CSS/Rule/Rule.php index 3fa031bd..4480948f 100644 --- a/lib/Sabberworm/CSS/Rule/Rule.php +++ b/lib/Sabberworm/CSS/Rule/Rule.php @@ -56,7 +56,6 @@ public static function parse(ParserState $oParserState) { while ($oParserState->comes(';')) { $oParserState->consume(';'); } - $oParserState->consumeWhiteSpace(); return $oRule; } diff --git a/tests/Sabberworm/CSS/ParserTest.php b/tests/Sabberworm/CSS/ParserTest.php index a6d95359..94bfcbf9 100644 --- a/tests/Sabberworm/CSS/ParserTest.php +++ b/tests/Sabberworm/CSS/ParserTest.php @@ -716,22 +716,28 @@ function testCommentExtracting() { } function testFlatCommentExtracting() { - $parser = new Parser('div {/*Find Me!*/left:10px; text-align:left;}'); + $parser = new Parser('div {/*Find Me!*/left:10px; /*Find Me Too!*/text-align:left;}'); $doc = $parser->parse(); $contents = $doc->getContents(); $divRules = $contents[0]->getRules(); - $comments = $divRules[0]->getComments(); - $this->assertCount(1, $comments); - $this->assertEquals("Find Me!", $comments[0]->getComment()); + $rule1Comments = $divRules[0]->getComments(); + $rule2Comments = $divRules[1]->getComments(); + $this->assertCount(1, $rule1Comments); + $this->assertCount(1, $rule2Comments); + $this->assertEquals("Find Me!", $rule1Comments[0]->getComment()); + $this->assertEquals("Find Me Too!", $rule2Comments[0]->getComment()); } function testTopLevelCommentExtracting() { - $parser = new Parser('/*Find Me!*/div {left:10px; text-align:left;}'); + $parser = new Parser('/*Find Me!*/div {left:10px; text-align:left;} /*Find Me Too!*/a {left:10px;}'); $doc = $parser->parse(); $contents = $doc->getContents(); - $comments = $contents[0]->getComments(); - $this->assertCount(1, $comments); - $this->assertEquals("Find Me!", $comments[0]->getComment()); + $list1Comments = $contents[0]->getComments(); + $list2Comments = $contents[1]->getComments(); + $this->assertCount(1, $list1Comments); + $this->assertCount(1, $list2Comments); + $this->assertEquals("Find Me!", $list1Comments[0]->getComment()); + $this->assertEquals("Find Me Too!", $list2Comments[0]->getComment()); } /**