Fixes #610 - `border:inherit` restoring.
authorJakub Pawlowicz <contact@jakubpawlowicz.com>
Wed, 24 Jun 2015 07:53:47 +0000 (08:53 +0100)
committerJakub Pawlowicz <contact@jakubpawlowicz.com>
Wed, 24 Jun 2015 08:25:33 +0000 (09:25 +0100)
Apparently `withoutDefaults` restoring suffered the same issue as
`background` property restoring - see #563.

History.md
lib/properties/restore.js
test/properties/restore-test.js

index bd5cdb9..209a5f3 100644 (file)
@@ -6,6 +6,7 @@
 [3.3.4 / 2015-xx-xx](https://github.com/jakubpawlowicz/clean-css/compare/v3.3.3...3.3)
 ==================
 
+* Fixed issue [#610](https://github.com/jakubpawlowicz/clean-css/issues/610) - `border:inherit` restoring.
 * Fixed issue [#611](https://github.com/jakubpawlowicz/clean-css/issues/611) - edge case in quote stripping.
 
 [3.3.3 / 2015-06-16](https://github.com/jakubpawlowicz/clean-css/compare/v3.3.2...v3.3.3)
index 8d49c7b..358e7a8 100644 (file)
@@ -199,6 +199,17 @@ function multiplex(restoreWith) {
   };
 }
 
+function _isInheritOnly(values) {
+  for (var i = 0, l = values.length; i < l; i++) {
+    var value = values[i][0];
+
+    if (value != 'inherit')
+      return false;
+  }
+
+  return true;
+}
+
 function withoutDefaults(property, compactable) {
   var components = property.components;
   var restored = [];
@@ -214,6 +225,9 @@ function withoutDefaults(property, compactable) {
   if (restored.length === 0)
     restored.push([compactable[property.name].defaultValue]);
 
+  if (_isInheritOnly(restored))
+    return [restored[0]];
+
   return restored;
 }
 
index 087534d..e8ccf4e 100644 (file)
@@ -170,6 +170,14 @@ vows.describe(restore)
         'gives right value back': function (restoredValue) {
           assert.deepEqual(restoredValue, [['0px'], ['1px'], ['2px'], ['3px'], ['/'], ['0px'], ['1px']]);
         }
+      },
+      'inherit': {
+        'topic': function () {
+          return _restore(_breakUp([['border'], ['inherit']]));
+        },
+        'gives right value back': function (restoredValue) {
+          assert.deepEqual(restoredValue, [['inherit']]);
+        }
       }
     },
     'four values': {