From: Jakub Pawlowicz Date: Tue, 3 Mar 2015 22:31:12 +0000 (+0000) Subject: Fixes #478 - whitespace after closing brace. X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=e09ddf17f634311498efcbc2e9b889ecf5c0a2c1;p=clean-css.git Fixes #478 - whitespace after closing brace. So instead of aiding tokenization on top level we should only alter body tags with a brace. It was naive to do it on the top level in the first place :/ --- diff --git a/History.md b/History.md index ae6a5d64..61b28940 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.4 / 2015-xx-xx](https://github.com/jakubpawlowicz/clean-css/compare/v3.1.3...3.1) +================== + +* Fixes issue [#478](https://github.com/jakubpawlowicz/clean-css/issues/478) - ultimate fix to brace whitespace. + [3.1.3 / 2015-03-03](https://github.com/jakubpawlowicz/clean-css/compare/v3.1.2...v3.1.3) ================== diff --git a/lib/selectors/tokenizer.js b/lib/selectors/tokenizer.js index 1874d30a..587174aa 100644 --- a/lib/selectors/tokenizer.js +++ b/lib/selectors/tokenizer.js @@ -14,9 +14,7 @@ function Tokenizer(minifyContext, addMetadata, addSourceMap) { } Tokenizer.prototype.toTokens = function (data) { - data = data - .replace(/\r\n/g, '\n') - .replace(/\)([^\s\{_;:,\.]|\.\d)/g, this.addSourceMap ? ') __ESCAPED_COMMENT_CLEAN_CSS(0,-1)__$1' : ') $1'); + data = data.replace(/\r\n/g, '\n'); var chunker = new Chunker(data, '}', 128); if (chunker.isEmpty()) diff --git a/lib/utils/extractors.js b/lib/utils/extractors.js index f3d08041..64d54f7a 100644 --- a/lib/utils/extractors.js +++ b/lib/utils/extractors.js @@ -21,6 +21,9 @@ var Extractors = { var token; var addSourceMap = context.addSourceMap; + if (string.replace && string.indexOf(')') > 0) + string = string.replace(/\)([^\s_;:,])/g, context.addSourceMap ? ') __ESCAPED_COMMENT_CLEAN_CSS(0,-1)__$1' : ') $1'); + for (var i = 0, l = string.length; i < l; i++) { current = string[i]; isPropertyEnd = current === ';'; diff --git a/test/integration-test.js b/test/integration-test.js index 46304d65..5da35fd9 100644 --- a/test/integration-test.js +++ b/test/integration-test.js @@ -190,9 +190,17 @@ vows.describe('integration tests').addBatch({ 'a{margin:calc(100% - 2px) calc(100% - 5px)}', 'a{margin:calc(100% - 2px)calc(100% - 5px)}' ], - 'after :not': [ + 'after :not #1': [ 'li:not(.foo).bar{color:red}', 'li:not(.foo).bar{color:red}' + ], + 'after :not #2': [ + 'li:not(.foo)[data-type=none]{color:red}', + 'li:not(.foo)[data-type=none]{color:red}' + ], + 'after :not #3': [ + 'li:not(.foo)#id{color:red}', + 'li:not(.foo)#id{color:red}' ] }), 'line breaks': cssContext({