Skip to content

Commit

Permalink
Fix #301 calc() not followed by end of line or semicolon not correctl…
Browse files Browse the repository at this point in the history
…y matched
  • Loading branch information
Simon authored and matthiasmullie committed Jan 21, 2020
1 parent a5c9d09 commit 9ba1b45
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/CSS.php
Original file line number Diff line number Diff line change
Expand Up @@ -708,7 +708,8 @@ protected function extractCalcs()
return $placeholder.$rest;
};

$this->registerPattern('/calc(\(.+?)(?=$|;|calc\()/m', $callback);
$this->registerPattern('/calc(\(.+?)(?=$|;|}|calc\()/', $callback);
$this->registerPattern('/calc(\(.+?)(?=$|;|}|calc\()/m', $callback);
}

/**
Expand Down
6 changes: 6 additions & 0 deletions tests/css/CSSTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,12 @@ public function dataProvider()
'.cvp-live-filter select{background-position:calc(100% - 20px) calc(1em + 2px),calc(100% - 15px) calc(1em + 2px),calc(100% - 2.5em) .5em}',
);

// https://github.com/matthiasmullie/minify/issues/301
$tests[] = array(
'.e-gallery-masonry .e-gallery-item{--percent-height: 0;position:absolute;width:calc(100% / var(--columns) - (var(--hgap) * (var(--columns) - 1) / var(--columns)));left:calc((100% / var(--columns) - (var(--hgap) * (var(--columns) - 1) / var(--columns))) * var(--column) + (var(--hgap) * var(--column)));top:calc(var(--percent-height) + (var(--row) * var(--vgap)))}.e-gallery-masonry .e-gallery-image{padding-bottom:var(--item-height)}',
'.e-gallery-masonry .e-gallery-item{--percent-height:0;position:absolute;width:calc(100% / var(--columns) - (var(--hgap) * (var(--columns) - 1) / var(--columns)));left:calc((100% / var(--columns) - (var(--hgap) * (var(--columns) - 1) / var(--columns))) * var(--column) + (var(--hgap) * var(--column)));top:calc(var(--percent-height) + (var(--row) * var(--vgap)))}.e-gallery-masonry .e-gallery-image{padding-bottom:var(--item-height)}',
);

// https://github.com/matthiasmullie/minify/issues/139
$tests[] = array(
__DIR__.'/sample/line_endings/lf/parent.css',
Expand Down

0 comments on commit 9ba1b45

Please sign in to comment.