Fixes #601 - minifying percentages inside `flex`.
authorJakub Pawlowicz <contact@jakubpawlowicz.com>
Sun, 14 Jun 2015 09:59:02 +0000 (10:59 +0100)
committerJakub Pawlowicz <contact@jakubpawlowicz.com>
Sun, 14 Jun 2015 14:56:53 +0000 (15:56 +0100)
Apparently IE10-11 do not like it.

History.md
lib/selectors/optimizers/simple.js
test/selectors/optimizers/simple-test.js

index d6544c2..0b9ef14 100644 (file)
@@ -1,3 +1,8 @@
+[3.3.2 / 2015-xx-xx](https://github.com/jakubpawlowicz/clean-css/compare/v3.3.1...3.3)
+==================
+
+* Fixed issue [#601](https://github.com/jakubpawlowicz/clean-css/issues/601) - percentage minifying inside `flex`.
+
 [3.3.1 / 2015-06-02](https://github.com/jakubpawlowicz/clean-css/compare/v3.3.0...v3.3.1)
 ==================
 
index 9ad66a1..6feb33f 100644 (file)
@@ -107,10 +107,13 @@ function precisionMinifier(_, value, precisionOptions) {
     .replace(/(\d)\.($|\D)/g, '$1$2');
 }
 
-function unitMinifier(_, value, unitsRegexp) {
+function unitMinifier(name, value, unitsRegexp) {
   if (/^(?:\-moz\-calc|\-webkit\-calc|calc)\(/.test(value))
     return value;
 
+  if (name == 'flex' || name == 'flex-basis')
+    return value;
+
   return value
     .replace(unitsRegexp, '$1' + '0' + '$2')
     .replace(unitsRegexp, '$1' + '0' + '$2');
index 76bfdc7..17c478d 100644 (file)
@@ -505,6 +505,14 @@ vows.describe(SimpleOptimizer)
       'inside calc': [
         'a{font-size:calc(100% + 0px)}',
         [['font-size', 'calc(100% + 0px)']]
+      ],
+      'flex': [
+        'a{flex: 1 0 0%}',
+        [['flex', '1', '0', '0%']]
+      ],
+      'flex–basis': [
+        'a{flex-basis:0%}',
+        [['flex-basis', '0%']]
       ]
     })
   )