Skip to content

Commit

Permalink
[BUGFIX] Revert broken support for multiple comments (#741)
Browse files Browse the repository at this point in the history
This reverts e4c66f6 (#672), which broke comment parsing in
strict mode.

We'll need to re-implement support for multiple comments later
in a way that does not break the existing comment parsing.

This is the v8.x backport of #740.
  • Loading branch information
oliverklee authored Oct 24, 2024
1 parent 404aff3 commit 81582a7
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 8 deletions.
1 change: 0 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ This project adheres to [Semantic Versioning](https://semver.org/).
### Fixed

- Fix type errors in PHP strict mode (#695)
- Fix comment parsing to support multiple comments (#671)

## 8.6.0

Expand Down
6 changes: 1 addition & 5 deletions src/Rule/Rule.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,7 @@ public static function parse(ParserState $oParserState)
$oParserState->consume(';');
}

// NOTE: This is a backport to fix comment parsing to support multiple
// comments. This will be rectified in version 9.0.0.
while (preg_match('/\\s/isSu', $oParserState->peek()) === 1) {
$oParserState->consume(1);
}
$oParserState->consumeWhiteSpace();

return $oRule;
}
Expand Down
3 changes: 3 additions & 0 deletions tests/ParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1172,11 +1172,14 @@ public function flatCommentExtractingOneComment()
self::assertCount(1, $comments);
self::assertSame("Find Me!", $comments[0]->getComment());
}

/**
* @test
*/
public function flatCommentExtractingTwoComments()
{
self::markTestSkipped('This is currently broken.');

$parser = new Parser('div {/*Find Me!*/left:10px; /*Find Me Too!*/text-align:left;}');
$doc = $parser->parse();
$contents = $doc->getContents();
Expand Down
2 changes: 0 additions & 2 deletions tests/RuleSet/DeclarationBlockTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -497,8 +497,6 @@ public function canRemoveCommentsFromRulesUsingStrictParsing(
$cssWithComments,
$cssWithoutComments
) {
self::markTestSkipped('This currently crashes, and we need to fix it.');

$parserSettings = ParserSettings::create()->withLenientParsing(false);
$document = (new Parser($cssWithComments, $parserSettings))->parse();

Expand Down

0 comments on commit 81582a7

Please sign in to comment.