Skip to content

Commit

Permalink
fix wrong descendant combinator removal (fixes #246)
Browse files Browse the repository at this point in the history
  • Loading branch information
lahmatiy committed Oct 20, 2015
1 parent b2ecb59 commit dd8709e
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/compressor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,12 @@ CSSOCompressor.prototype.cleanWhitespace = function(token, rule, parent, i) {
if (nextType === 'unknown') {
token[2] = '\n';
} else {
if ((parentType !== 'atrulerq' || prevType) &&
if (parentType === 'simpleselector') {
if (!prevType || prevType === 'combinator' ||
!nextType || nextType === 'combinator') {
return null;
}
} else if ((parentType !== 'atrulerq' || prevType) &&
!this.issue16(prevType, nextType) &&
!this.issue165(parent, prevType, nextType) &&
!this.issue134(prevType, nextType) &&
Expand Down
14 changes: 14 additions & 0 deletions test/fixture/compress/selector/1.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*
issue #246:
shouldn't remove descendant combinator
*/

div.dropdown * {
color: #ff0000;
}
* div {
color: blue;
}
a b {
color: green;
}
1 change: 1 addition & 0 deletions test/fixture/compress/selector/1.min.css
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
div.dropdown *{color:red}* div{color:#00f}a b{color:green}

0 comments on commit dd8709e

Please sign in to comment.