Skip to content

Commit 9ba1b45

Browse files
simondudmatthiasmullie
authored andcommitted
Fix #301 calc() not followed by end of line or semicolon not correctly matched
1 parent a5c9d09 commit 9ba1b45

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

src/CSS.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -708,7 +708,8 @@ protected function extractCalcs()
708708
return $placeholder.$rest;
709709
};
710710

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

714715
/**

tests/css/CSSTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -505,6 +505,12 @@ public function dataProvider()
505505
'.cvp-live-filter select{background-position:calc(100% - 20px) calc(1em + 2px),calc(100% - 15px) calc(1em + 2px),calc(100% - 2.5em) .5em}',
506506
);
507507

508+
// https://github.com/matthiasmullie/minify/issues/301
509+
$tests[] = array(
510+
'.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)}',
511+
'.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)}',
512+
);
513+
508514
// https://github.com/matthiasmullie/minify/issues/139
509515
$tests[] = array(
510516
__DIR__.'/sample/line_endings/lf/parent.css',

0 commit comments

Comments
 (0)