From 2292a60eddac32b00bc36f70d4b38844c3f60c1e Mon Sep 17 00:00:00 2001 From: frank goossens Date: Sat, 28 Nov 2015 10:53:24 +0100 Subject: [PATCH] potential fix for issue 26 cfr. https://github.com/tubalmartin/YUI-CSS-compressor-PHP-port/issues/26 --- cssmin.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/cssmin.php b/cssmin.php index fab0102..a204e4c 100644 --- a/cssmin.php +++ b/cssmin.php @@ -264,6 +264,9 @@ private function minify($css, $linebreak_pos) // Normalize all whitespace strings to single spaces. Easier to work with that way. $css = preg_replace('/\s+/', ' ', $css); + // preserve flex, keeping percentage even if 0 + $css = preg_replace_callback('/flex\s?:\s?((?:[0-9 ]*)\s?(?:px|em|auto|%)?(?:calc\(.*\))?)/i',array($this, 'replace_flex'),$css); + // Fix IE7 issue on matrix filters which browser accept whitespaces between Matrix parameters $css = preg_replace_callback('/\s*filter\:\s*progid:DXImageTransform\.Microsoft\.Matrix\(([^\)]+)\)/', array($this, 'preserve_old_IE_specific_matrix_definition'), $css); @@ -590,6 +593,12 @@ private function replace_calc($matches) return 'calc('. self::TOKEN . (count($this->preserved_tokens) - 1) . '___' . ')'; } + private function replace_flex($matches) + { + $this->preserved_tokens[] = trim($matches[1]); + return 'flex:'.self::TOKEN . (count($this->preserved_tokens) - 1) . '___'; + } + private function preserve_old_IE_specific_matrix_definition($matches) { $this->preserved_tokens[] = $matches[1];