diff --git a/packages/postcss-convert-values/src/__tests__/index.js b/packages/postcss-convert-values/src/__tests__/index.js index b767ceff4..425661216 100644 --- a/packages/postcss-convert-values/src/__tests__/index.js +++ b/packages/postcss-convert-values/src/__tests__/index.js @@ -67,6 +67,11 @@ test( processCSS('h1{width:100.00%}', 'h1{width:100%}') ); +test( + 'should preserve opacities defined as percentages', + passthroughCSS('h1{opacity:100%}') +); + test('should not mangle flex basis', passthroughCSS('h1{flex-basis:0%}')); test('should not mangle flex basis (2)', passthroughCSS('h1{FLEX-BASIC:0%}')); diff --git a/packages/postcss-convert-values/src/index.js b/packages/postcss-convert-values/src/index.js index a8b0f9ce2..7da38f84b 100644 --- a/packages/postcss-convert-values/src/index.js +++ b/packages/postcss-convert-values/src/index.js @@ -53,7 +53,7 @@ function clampOpacity(node) { } let num = Number(pair.number); if (num > 1) { - node.value = 1 + pair.unit; + node.value = pair.unit === '%' ? num + pair.unit : 1 + pair.unit; } else if (num < 0) { node.value = 0 + pair.unit; }