From 5c99900f2989837a14844dc75d948b36637b728a Mon Sep 17 00:00:00 2001 From: Jakub Pawlowicz Date: Mon, 16 Mar 2015 18:52:29 +0000 Subject: [PATCH] Fixes #496 - space after bracket removal inside `calc`. In case of `) -` and `) +` in `calc` expressions a space should not be removed at all times. --- History.md | 5 +++++ lib/selectors/optimizers/simple.js | 4 ++-- test/integration-test.js | 4 ++++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/History.md b/History.md index 1f9e3d27..4bceb22d 100644 --- a/History.md +++ b/History.md @@ -7,6 +7,11 @@ * Fixed issue [#396](https://github.com/jakubpawlowicz/clean-css/issues/396) - better input source maps tracking. * Fixed issue [#480](https://github.com/jakubpawlowicz/clean-css/issues/480) - extracting uppercase property names. +[3.1.7 / 2015-xx-xx](https://github.com/jakubpawlowicz/clean-css/compare/v3.1.6...3.1) +================== + +* Fixes issue [#496](https://github.com/jakubpawlowicz/clean-css/issues/496) - space after bracket removal. + [3.1.6 / 2015-03-12](https://github.com/jakubpawlowicz/clean-css/compare/v3.1.5...v3.1.6) ================== diff --git a/lib/selectors/optimizers/simple.js b/lib/selectors/optimizers/simple.js index b221c313..a9bd64d8 100644 --- a/lib/selectors/optimizers/simple.js +++ b/lib/selectors/optimizers/simple.js @@ -176,10 +176,10 @@ function colorMininifier(property, value, compatibility) { } function spaceMinifier(property, value) { - if (property == 'filter' || processable.implementedFor.test(property)) + if (property == 'filter' || value.indexOf(') ') == -1 || processable.implementedFor.test(property)) return value; - return value.replace(/\) /g, ')'); + return value.replace(/\) ((?![\+\-] )|$)/g, ')$1'); } function reduce(body, options) { diff --git a/test/integration-test.js b/test/integration-test.js index 503b4eb7..ce740dfe 100644 --- a/test/integration-test.js +++ b/test/integration-test.js @@ -136,6 +136,10 @@ vows.describe('integration tests').addBatch({ 'body{margin-left:calc(50vw + (1024px/2))}', 'body{margin-left:calc(50vw + (1024px/2))}' ], + 'not inside calc method with brackets #2': [ + 'body{width:calc((978px * 2/3) - 30px)}', + 'body{width:calc((978px * 2/3) - 30px)}' + ], 'with space between braces': [ 'body{width:calc( ( 100% - 12px) / 3 )}', 'body{width:calc((100% - 12px)/ 3)}' -- 2.34.1