Skip to content

Commit

Permalink
Fixes #957 - 0% minification of width property.
Browse files Browse the repository at this point in the history
Why:

* Apparently `width` and `max-width` `0%` value cannot be turned into
  `0`, see: https://codepen.io/judowalker/pen/xrMxWj
  • Loading branch information
jakubpawlowicz committed Jul 14, 2017
1 parent 8c63ce0 commit 5120ea4
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 @@
[4.1.7 / 2017-xx-xx](https://github.com/jakubpawlowicz/clean-css/compare/v4.1.6...4.1)
==================

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

[4.1.6 / 2017-07-08](https://github.com/jakubpawlowicz/clean-css/compare/v4.1.5...v4.1.6)
==================

Expand Down
2 changes: 1 addition & 1 deletion lib/optimizer/level-1/optimize.js
Expand Up @@ -269,7 +269,7 @@ function optimizeUnits(name, value, unitsRegexp) {
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;
}

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

0 comments on commit 5120ea4

Please sign in to comment.