From 5c9f33e582ec088a6d0d4cd10c9e277608599275 Mon Sep 17 00:00:00 2001 From: Jakub Pawlowicz Date: Sat, 7 Feb 2015 12:16:07 +0000 Subject: [PATCH] Fixes #455 - whitespace between braces. `( (` was handled incorrectly as the first brace got removed. --- History.md | 1 + lib/utils/extractors.js | 4 +++- test/integration-test.js | 4 ++++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index abbd3e27..507093d4 100644 --- a/History.md +++ b/History.md @@ -19,6 +19,7 @@ ================== * Fixed issue [#453](https://github.com/jakubpawlowicz/clean-css/issues/453) - double `background-repeat`. +* Fixed issue [#455](https://github.com/jakubpawlowicz/clean-css/issues/455) - property extracting regression. [3.0.9 / 2015-02-04](https://github.com/jakubpawlowicz/clean-css/compare/v3.0.8...v3.0.9) ================== diff --git a/lib/utils/extractors.js b/lib/utils/extractors.js index e19c7681..0cc78700 100644 --- a/lib/utils/extractors.js +++ b/lib/utils/extractors.js @@ -14,6 +14,7 @@ var Extractors = { var isSpecial; var wasSpecial; var current; + var last; var secondToLast; var wasCloseParenthesis; var isEscape; @@ -66,8 +67,9 @@ var Extractors = { isSpecial = current === ':' || current === '[' || current === ']' || current === ',' || current === '(' || current === ')'; if (wasWhitespace && isSpecial) { + last = buffer[buffer.length - 1]; secondToLast = buffer[buffer.length - 2]; - if (secondToLast != '+' && secondToLast != '-' && secondToLast != '/' && secondToLast != '*') + if (secondToLast != '+' && secondToLast != '-' && secondToLast != '/' && secondToLast != '*' && last != '(') buffer.pop(); buffer.push(current); } else if (isWhitespace && wasSpecial && !wasCloseParenthesis) { diff --git a/test/integration-test.js b/test/integration-test.js index 17f851f5..d2eacb3b 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))}' ], + 'with space between braces': [ + 'body{width:calc( ( 100% - 12px) / 3 )}', + 'body{width:calc((100% - 12px)/ 3)}' + ], 'before colon': [ '#test{padding-left :0}', '#test{padding-left:0}' -- 2.34.1