diff --git a/lib/compressor/compress/Dimension.js b/lib/compressor/compress/Dimension.js index 6cfa693a..b69030fa 100644 --- a/lib/compressor/compress/Dimension.js +++ b/lib/compressor/compress/Dimension.js @@ -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; } diff --git a/lib/compressor/compress/Value.js b/lib/compressor/compress/Value.js index ed42670f..afcc02c9 100644 --- a/lib/compressor/compress/Value.js +++ b/lib/compressor/compress/Value.js @@ -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)) { diff --git a/test/fixture/compress/atrules/supports-2.css b/test/fixture/compress/atrules/supports-2.css index f8f1deb6..75a84902 100644 --- a/test/fixture/compress/atrules/supports-2.css +++ b/test/fixture/compress/atrules/supports-2.css @@ -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 { diff --git a/test/fixture/compress/atrules/supports-2.min.css b/test/fixture/compress/atrules/supports-2.min.css index 97137201..c039ec82 100644 --- a/test/fixture/compress/atrules/supports-2.min.css +++ b/test/fixture/compress/atrules/supports-2.min.css @@ -1 +1 @@ -@supports (width:0) and (test:0deg){.test{foo:1}} +@supports (width:0px) and (test:0deg){.test{foo:1}}