Skip to content

Commit

Permalink
Backports #957 - 0% minification of width property.
Browse files Browse the repository at this point in the history
  • Loading branch information
jakubpawlowicz committed Jul 14, 2017
1 parent a6f97c3 commit bd847de
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
5 changes: 5 additions & 0 deletions History.md
@@ -1,3 +1,8 @@
[3.4.28 / 2017-xx-xx](https://github.com/jakubpawlowicz/clean-css/compare/v3.4.27...3.4)
==================

* Backports [#957](https://github.com/jakubpawlowicz/clean-css/issues/957) - `0%` minification of `width` property.

[3.4.27 / 2017-06-09](https://github.com/jakubpawlowicz/clean-css/compare/v3.4.26...v3.4.27)
==================

Expand Down
2 changes: 1 addition & 1 deletion lib/selectors/simple.js
Expand Up @@ -104,7 +104,7 @@ function unitMinifier(name, value, unitsRegexp) {
if (name == 'flex' || name == '-ms-flex' || name == '-webkit-flex' || name == 'flex-basis' || name == '-webkit-flex-basis')
return value;

if (value.indexOf('%') > 0 && (name == 'height' || name == 'max-height'))
if (value.indexOf('%') > 0 && (name == 'height' || name == 'max-height' || name == 'width' || name == 'max-width'))
return value;

return value
Expand Down
16 changes: 14 additions & 2 deletions test/selectors/simple-test.js
Expand Up @@ -611,8 +611,8 @@ vows.describe('simple optimizations')
[['margin', '0']]
],
'-0% to 0': [
'a{width:-0%}',
[['width', '0']]
'a{min-width:-0%}',
[['min-width', '0']]
],
'missing': [
'a{opacity:1.}',
Expand Down Expand Up @@ -689,6 +689,18 @@ vows.describe('simple optimizations')
'max-height': [
'a{max-height:0%}',
[['max-height', '0%']]
],
'width': [
'a{width:0%}',
[['width', '0%']]
],
'min-width': [
'a{min-width:0%}',
[['min-width', '0']]
],
'max-width': [
'a{max-width:0%}',
[['max-width', '0%']]
]
})
)
Expand Down

0 comments on commit bd847de

Please sign in to comment.