Skip to content

Commit

Permalink
Fixes #750 - allows width overriding.
Browse files Browse the repository at this point in the history
Why:

* Width can be overriden easily using `unit` overrider.
  • Loading branch information
jakubpawlowicz committed Jan 1, 2017
1 parent 2e56d85 commit b809a36
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 0 deletions.
1 change: 1 addition & 0 deletions History.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
* Fixed issue [#686](https://github.com/jakubpawlowicz/clean-css/issues/686) - adds rounding precision for all units.
* Fixed issue [#703](https://github.com/jakubpawlowicz/clean-css/issues/703) - changes default IE compatibility to 10+.
* Fixed issue [#739](https://github.com/jakubpawlowicz/clean-css/issues/739) - error when a closing brace is missing.
* Fixed issue [#750](https://github.com/jakubpawlowicz/clean-css/issues/750) - allows `width` overriding.
* Fixed issue [#756](https://github.com/jakubpawlowicz/clean-css/issues/756) - adds disabling font-weight optimizations.
* Fixed issue [#758](https://github.com/jakubpawlowicz/clean-css/issues/758) - ignores rules with empty selector.
* Fixed issue [#767](https://github.com/jakubpawlowicz/clean-css/issues/767) - disables remote `@import` inlining by default.
Expand Down
5 changes: 5 additions & 0 deletions lib/properties/compactable.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,11 @@ var compactable = {
},
'transform': {
canOverride: canOverride.sameFunctionOrValue
},
'width': {
canOverride: canOverride.unit,
defaultValue: 'auto',
shortestValue: '0'
}
};

Expand Down
8 changes: 8 additions & 0 deletions test/optimizer/advanced-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,12 @@ vows.describe('advanced optimizer')
]
})
)
.addBatch(
optimizerContext('unit compacting', {
'width': [
'div{width:1rem;width:16px}',
'div{width:16px}'
]
})
)
.export(module);
35 changes: 35 additions & 0 deletions test/properties/override-compacting-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1606,4 +1606,39 @@ vows.describe(optimize)
}
}
})
.addBatch({
'one unit value': {
'topic': function () {
return _optimize('a{width:3px;width:4px}');
},
'into': function (properties) {
assert.deepEqual(properties, [
[
'property',
['property-name', 'width', [[1, 12, undefined]]],
['property-value', '4px', [[1, 18, undefined]]]
]
]);
}
},
'incompatible unit values': {
'topic': function () {
return _optimize('a{width:4px;width:calc(5rem / 2)}');
},
'into': function (properties) {
assert.deepEqual(properties, [
[
'property',
['property-name', 'width', [[1, 2, undefined]]],
['property-value', '4px', [[1, 8, undefined]]]
],
[
'property',
['property-name', 'width', [[1, 12, undefined]]],
['property-value', 'calc(5rem / 2)', [[1, 18, undefined]]]
]
]);
}
}
})
.export(module);

0 comments on commit b809a36

Please sign in to comment.