From: Jakub Pawlowicz Date: Sat, 31 Dec 2016 18:02:31 +0000 (+0100) Subject: Fixes #750 - allows `width` overriding. X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=b809a36e7b56efc0ae6bac80135ea6d67853433b;p=clean-css.git Fixes #750 - allows `width` overriding. Why: * Width can be overriden easily using `unit` overrider. --- diff --git a/History.md b/History.md index b610d291..3c846c7f 100644 --- a/History.md +++ b/History.md @@ -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. diff --git a/lib/properties/compactable.js b/lib/properties/compactable.js index 9abc2df6..ca0657da 100644 --- a/lib/properties/compactable.js +++ b/lib/properties/compactable.js @@ -190,6 +190,11 @@ var compactable = { }, 'transform': { canOverride: canOverride.sameFunctionOrValue + }, + 'width': { + canOverride: canOverride.unit, + defaultValue: 'auto', + shortestValue: '0' } }; diff --git a/test/optimizer/advanced-test.js b/test/optimizer/advanced-test.js index 01cdbb09..d89a81cc 100644 --- a/test/optimizer/advanced-test.js +++ b/test/optimizer/advanced-test.js @@ -86,4 +86,12 @@ vows.describe('advanced optimizer') ] }) ) + .addBatch( + optimizerContext('unit compacting', { + 'width': [ + 'div{width:1rem;width:16px}', + 'div{width:16px}' + ] + }) + ) .export(module); diff --git a/test/properties/override-compacting-test.js b/test/properties/override-compacting-test.js index 1c0f04b8..7ad2f1d5 100644 --- a/test/properties/override-compacting-test.js +++ b/test/properties/override-compacting-test.js @@ -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);