Skip to content

Commit

Permalink
Fixes #754 - treats empty rule as unmergeable.
Browse files Browse the repository at this point in the history
Firefox and Chrome just ignore such rules while IE ignores empty rule
and interprets the rest correctly. This means it could be used as a
IE hack.
  • Loading branch information
jakubpawlowicz committed Apr 9, 2016
1 parent c0d4f4a commit 4c988ce
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 3 deletions.
1 change: 1 addition & 0 deletions History.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
==================

* Fixed issue [#734](https://github.com/jakubpawlowicz/clean-css/issues/734) - `--root` option edge case.
* Fixed issue [#758](https://github.com/jakubpawlowicz/clean-css/issues/758) - treats empty rule as unmergeable.

[3.4.11 / 2016-04-01](https://github.com/jakubpawlowicz/clean-css/compare/v3.4.10...v3.4.11)
==================
Expand Down
6 changes: 3 additions & 3 deletions lib/utils/compatibility.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ var DEFAULTS = {
selectors: {
adjacentSpace: false, // div+ nav Android stock browser hack
ie7Hack: false, // *+html hack
special: /(\-moz\-|\-ms\-|\-o\-|\-webkit\-|:dir\([a-z-]*\)|:first(?![a-z-])|:fullscreen|:left|:read-only|:read-write|:right|:placeholder|:host|::content|\/deep\/|::shadow)/ // special selectors which prevent merging
special: /(\-moz\-|\-ms\-|\-o\-|\-webkit\-|:dir\([a-z-]*\)|:first(?![a-z-])|:fullscreen|:left|:read-only|:read-write|:right|:placeholder|:host|::content|\/deep\/|::shadow|^,)/ // special selectors which prevent merging
},
units: {
ch: true,
Expand Down Expand Up @@ -58,7 +58,7 @@ var DEFAULTS = {
selectors: {
adjacentSpace: false,
ie7Hack: false,
special: /(\-moz\-|\-ms\-|\-o\-|\-webkit\-|:root|:nth|:first\-of|:last|:only|:empty|:target|:checked|::selection|:enabled|:disabled|:not|:placeholder|:host|::content|\/deep\/|::shadow)/
special: /(\-moz\-|\-ms\-|\-o\-|\-webkit\-|:root|:nth|:first\-of|:last|:only|:empty|:target|:checked|::selection|:enabled|:disabled|:not|:placeholder|:host|::content|\/deep\/|::shadow|^,)/
},
units: {
ch: false,
Expand Down Expand Up @@ -94,7 +94,7 @@ var DEFAULTS = {
selectors: {
adjacentSpace: false,
ie7Hack: true,
special: /(\-moz\-|\-ms\-|\-o\-|\-webkit\-|:focus|:before|:after|:root|:nth|:first\-of|:last|:only|:empty|:target|:checked|::selection|:enabled|:disabled|:not|:placeholder|:host|::content|\/deep\/|::shadow)/
special: /(\-moz\-|\-ms\-|\-o\-|\-webkit\-|:focus|:before|:after|:root|:nth|:first\-of|:last|:only|:empty|:target|:checked|::selection|:enabled|:disabled|:not|:placeholder|:host|::content|\/deep\/|::shadow|^,)/
},
units: {
ch: false,
Expand Down
8 changes: 8 additions & 0 deletions test/selectors/merge-adjacent-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,14 @@ vows.describe('remove duplicates')
'two rules with latter with suffix properties': [
'a{display:none}a{display:none;visibility:hidden}',
'a{display:none;visibility:hidden}'
],
'no rule after comma': [
'h1{color:#000},h2{color:#000}',
'h1{color:#000},h2{color:#000}'
],
'no rule after comma with comma last': [
'h1{color:#000}h2,{color:#000}',
'h1{color:#000},h2{color:#000}'
]
})
)
Expand Down
4 changes: 4 additions & 0 deletions test/selectors/merge-non-adjacent-by-body-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ vows.describe('merge non djacent by body')
'of element selectors with an empty class selector in between': [
'p{color:red}.a{}div{color:red}',
'div,p{color:red}'
],
'no rule after comma': [
'h1{color:#000}div{color:red},h2{color:#000}',
'h1{color:#000}div{color:red},h2{color:#000}'
]
})
)
Expand Down
4 changes: 4 additions & 0 deletions test/selectors/restructure-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,10 @@ vows.describe('restructure')
'with different vendor prefixed value group': [
'a{-moz-box-sizing:content-box;box-sizing:content-box}div{color:red}p{-moz-box-sizing:content-box;-webkit-box-sizing:content-box;box-sizing:content-box}',
'a{-moz-box-sizing:content-box;box-sizing:content-box}div{color:red}p{-moz-box-sizing:content-box;-webkit-box-sizing:content-box;box-sizing:content-box}'
],
'no rule after comma': [
'h1{color:#000}div{color:red},h2{color:#000;display:block}',
'h1{color:#000}div{color:red},h2{color:#000;display:block}'
]
})
)
Expand Down

0 comments on commit 4c988ce

Please sign in to comment.