Skip to content

Commit

Permalink
Fixes #610 - border:inherit restoring.
Browse files Browse the repository at this point in the history
Apparently `withoutDefaults` restoring suffered the same issue as
`background` property restoring - see #563.
  • Loading branch information
jakubpawlowicz committed Jun 24, 2015
1 parent cb0cf00 commit 134b2c3
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions History.md
Expand Up @@ -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)
Expand Down
14 changes: 14 additions & 0 deletions lib/properties/restore.js
Expand Up @@ -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 = [];
Expand All @@ -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;
}

Expand Down
8 changes: 8 additions & 0 deletions test/properties/restore-test.js
Expand Up @@ -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': {
Expand Down

0 comments on commit 134b2c3

Please sign in to comment.