Skip to content

Commit 63cfe5b

Browse files
committed
CSS minification bug fixed
1 parent cdd8b85 commit 63cfe5b

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

bin/minify.class.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ public static function css ($string="") {
109109
"/(\[)([^\"' \]]+)([\"'])([^\"' \]]+)(\\3)(\])/",
110110
"/ (\!important)/",
111111
"/\:(\:before|\:after)/",
112-
"/ ?([\(\)\{\}\:\;\,]) /",
112+
"/([\{\}\:\;\,]) /",
113113
"/(margin|padding|border-width|border-color|border-style)\:([0-9a-z\.\-\%]+)(\s+\\2)*([!;}])/i",
114114
"/(margin|padding|border-width|border-color|border-style)\:([0-9a-z\.\-\%]+)(\s+[0-9a-z\.\-\%]+)(\s+\\2)(\\3)*([!;}])/i"
115115
),
@@ -129,7 +129,7 @@ public static function css ($string="") {
129129
'$1$2$4$6',
130130
'$1',
131131
'$1',
132-
'$1 ',
132+
'$1',
133133
'$1:$2$4',
134134
'$1:$2$3$6'
135135
),
@@ -138,10 +138,10 @@ public static function css ($string="") {
138138
$string = preg_replace_callback('/\:\s*calc\(([^;}]+)/', function ($m) {
139139
return preg_replace(array('/\s+/', '/([-+*\/]+)/'), array('', ' $1 '), $m[0]);
140140
}, $string);
141-
$string = preg_replace_callback('/(.)(rgba?|hsla?)\s*\(\s*(\d+)[, %]+(\d+)[, %]+(\d+)[, %]*([01]?)\s*\)(.)/', function ($m) {
142-
if ($m[6] === '0') return $m[1].'transparent'.$m[7];
141+
$string = preg_replace_callback('/(.)(rgba?|hsla?)\s*\(\s*(\d+)[, %]+(\d+)[, %]+(\d+)[, %]*([01]?)\s*\)/', function ($m) {
142+
if ($m[6] === '0') return $m[1].'transparent';
143143
$type = str_replace('a', '', strtolower($m[2]));
144-
return $m[1].($type == 'hsl' ? self::hsl2hex($m[3]*1, $m[4]*1, $m[5]*1) : self::rgb2hex($m[3]*1, $m[4]*1, $m[5]*1)).$m[7];
144+
return $m[1].($type == 'hsl' ? self::hsl2hex($m[3]*1, $m[4]*1, $m[5]*1) : self::rgb2hex($m[3]*1, $m[4]*1, $m[5]*1));
145145
}, $string);
146146
$string = preg_replace("/([,: \(]#)([0-9a-f])\\2([0-9a-f])\\3([0-9a-f])\\4/i", '$1$2$3$4', $string);
147147
return trim($string);

0 commit comments

Comments
 (0)