Speeds up minifying zero values.
authorJakub Pawlowicz <contact@jakubpawlowicz.com>
Mon, 6 Oct 2014 11:17:03 +0000 (12:17 +0100)
committerJakub Pawlowicz <contact@jakubpawlowicz.com>
Fri, 10 Oct 2014 20:22:45 +0000 (21:22 +0100)
* Checks if zeros are present in property value before proceeding.

lib/selectors/optimizers/simple.js

index fda627e..5383da6 100644 (file)
@@ -89,6 +89,9 @@ var valueMinifiers = {
 };
 
 function zeroMinifier(_, value) {
+  if (value.indexOf('0') == -1)
+    return value;
+
   return value
     .replace(/\-0$/g, '0')
     .replace(/\-0([^\.])/g, '0$1')
@@ -120,6 +123,9 @@ function unitMinifier(_, value, unitsRegexp) {
 }
 
 function multipleZerosMinifier(property, value) {
+  if (value.indexOf('0 0 0 0') == -1)
+    return value;
+
   if (property.indexOf('box-shadow') > -1)
     return value == '0 0 0 0' ? '0 0' : value;