Skip to content

Commit

Permalink
don't compress values and zero length dimensions outside declaration
Browse files Browse the repository at this point in the history
  • Loading branch information
lahmatiy committed Feb 28, 2016
1 parent bfac3b2 commit d75201c
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
4 changes: 2 additions & 2 deletions lib/compressor/compress/Dimension.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ module.exports = function compressDimension(node, item) {

node.value = value;

if (value === '0' && !NON_LENGTH_UNIT.hasOwnProperty(unit)) {
if (value === '0' && this.declaration && !NON_LENGTH_UNIT.hasOwnProperty(unit)) {
// issue #200: don't remove units in flex property as it could change value meaning
if (this.declaration && this.declaration.property.name === 'flex') {
if (this.declaration.property.name === 'flex') {
return;
}

Expand Down
4 changes: 4 additions & 0 deletions lib/compressor/compress/Value.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ var compressFontWeight = require('./property/font-weight.js');
var compressBackground = require('./property/background.js');

module.exports = function compressValue(node) {
if (!this.declaration) {
return;
}

var property = this.declaration.property.name;

if (/background$/.test(property)) {
Expand Down
2 changes: 1 addition & 1 deletion test/fixture/compress/atrules/supports-2.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
issue #273 should compress length dimension outside block
issue #273 shouldn't compress length dimension outside declaration
*/
@supports (width: 0px) and (test: 0deg) {
.test {
Expand Down
2 changes: 1 addition & 1 deletion test/fixture/compress/atrules/supports-2.min.css
Original file line number Diff line number Diff line change
@@ -1 +1 @@
@supports (width:0) and (test:0deg){.test{foo:1}}
@supports (width:0px) and (test:0deg){.test{foo:1}}

0 comments on commit d75201c

Please sign in to comment.