From: Jakub Pawlowicz Date: Wed, 24 Jun 2015 07:53:47 +0000 (+0100) Subject: Fixes #610 - `border:inherit` restoring. X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=134b2c3728bc25a1ea4f32f090d408c90bb81ee8;p=clean-css.git Fixes #610 - `border:inherit` restoring. Apparently `withoutDefaults` restoring suffered the same issue as `background` property restoring - see #563. --- diff --git a/History.md b/History.md index bd5cdb96..209a5f31 100644 --- a/History.md +++ b/History.md @@ -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) diff --git a/lib/properties/restore.js b/lib/properties/restore.js index 8d49c7be..358e7a8a 100644 --- a/lib/properties/restore.js +++ b/lib/properties/restore.js @@ -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; } diff --git a/test/properties/restore-test.js b/test/properties/restore-test.js index 087534d5..e8ccf4e5 100644 --- a/test/properties/restore-test.js +++ b/test/properties/restore-test.js @@ -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': {