Skip to content

Commit

Permalink
Universal selector can follow a comment (#32)
Browse files Browse the repository at this point in the history
Fixes #31. Related: wintercms/winter#325
  • Loading branch information
damsfx authored May 9, 2022
1 parent 895fd7e commit f5fd341
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Assetic/Filter/StylesheetMinifyFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ protected function minify($css)
$css = preg_replace('/(\s+)(\/\*[^!](.*?)\*\/)(\s+)/', '$2', $css);

// Remove comment blocks, everything between /* and */, ignore /*! comments
$css = preg_replace('#/\*[^\!].*?\*/#s', '', $css);
$css = preg_replace('#/\*[^(\!|,|{)].*?\*/#s', '', $css);

// Remove ; before }
$css = preg_replace('/;(?=\s*})/', '', $css);
Expand Down
12 changes: 12 additions & 0 deletions tests/Assetic/Test/Filter/StylesheetMinifyFilterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,18 @@ public function testSpecialCommentPreservation()
$this->assertEquals($output, $mockAsset->getContent());
}

public function testUniversalSelectorFollowComment()
{
$input = '/*! Keep me */*{box-sizing:border-box}/* Remove me */.noborder{border:0}';
$output = '/*! Keep me */*{box-sizing:border-box}.noborder{border:0}';

$mockAsset = new MockAsset($input);
$result = new StylesheetMinifyFilter();
$result->filterDump($mockAsset);

$this->assertEquals($output, $mockAsset->getContent());
}

public function testCommentRemoval()
{
$input = 'body{/* First comment */} /* Second comment */';
Expand Down

0 comments on commit f5fd341

Please sign in to comment.