From d77533a83aa2f0dd81da01dec98287afd09a28e8 Mon Sep 17 00:00:00 2001 From: Jakub Pawlowicz Date: Mon, 2 Mar 2015 22:24:17 +0000 Subject: [PATCH] Fixes #475 - correctly handle whitespace after closing bracket. There was an issue with `:not(...).class` turned into `:not(...) .class`. --- History.md | 5 +++++ lib/selectors/tokenizer.js | 2 +- test/integration-test.js | 8 ++++++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index a64eef8a..e1658c78 100644 --- a/History.md +++ b/History.md @@ -3,6 +3,11 @@ * Fixed issue [#396](https://github.com/jakubpawlowicz/clean-css/issues/396) - better input source maps tracking. +[3.1.3 / 2015-xx-xx](https://github.com/jakubpawlowicz/clean-css/compare/v3.1.2...3.1) +================== + +* Fixes issue [#475](https://github.com/jakubpawlowicz/clean-css/issues/475) - whitespace after closing brace. + [3.1.2 / 2015-03-01](https://github.com/jakubpawlowicz/clean-css/compare/v3.1.1...v3.1.2) ================== diff --git a/lib/selectors/tokenizer.js b/lib/selectors/tokenizer.js index 39a0205a..1874d30a 100644 --- a/lib/selectors/tokenizer.js +++ b/lib/selectors/tokenizer.js @@ -16,7 +16,7 @@ function Tokenizer(minifyContext, addMetadata, addSourceMap) { Tokenizer.prototype.toTokens = function (data) { data = data .replace(/\r\n/g, '\n') - .replace(/\)([^\s\{_;:,])/g, this.addSourceMap ? ') __ESCAPED_COMMENT_CLEAN_CSS(0,-1)__$1' : ') $1'); + .replace(/\)([^\s\{_;:,\.]|\.\d)/g, this.addSourceMap ? ') __ESCAPED_COMMENT_CLEAN_CSS(0,-1)__$1' : ') $1'); var chunker = new Chunker(data, '}', 128); if (chunker.isEmpty()) diff --git a/test/integration-test.js b/test/integration-test.js index fdc9262a..46304d65 100644 --- a/test/integration-test.js +++ b/test/integration-test.js @@ -182,9 +182,17 @@ vows.describe('integration tests').addBatch({ 'a{background:calc(100% - 2px) 10px no-repeat}', 'a{background:calc(100% - 2px)10px no-repeat}' ], + 'inside background with fraction unit': [ + 'a{background:calc(100% - 2px).5em no-repeat}', + 'a{background:calc(100% - 2px).5em no-repeat}' + ], 'inside margin': [ 'a{margin:calc(100% - 2px) calc(100% - 5px)}', 'a{margin:calc(100% - 2px)calc(100% - 5px)}' + ], + 'after :not': [ + 'li:not(.foo).bar{color:red}', + 'li:not(.foo).bar{color:red}' ] }), 'line breaks': cssContext({ -- 2.34.1