Fixes #478 - whitespace after closing brace.
authorJakub Pawlowicz <contact@jakubpawlowicz.com>
Tue, 3 Mar 2015 22:31:12 +0000 (22:31 +0000)
committerJakub Pawlowicz <contact@jakubpawlowicz.com>
Wed, 4 Mar 2015 10:27:36 +0000 (10:27 +0000)
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 :/

History.md
lib/selectors/tokenizer.js
lib/utils/extractors.js
test/integration-test.js

index ae6a5d6..61b2894 100644 (file)
@@ -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)
 ==================
 
index 1874d30..587174a 100644 (file)
@@ -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())
index f3d0804..64d54f7 100644 (file)
@@ -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 === ';';
index 46304d6..5da35fd 100644 (file)
@@ -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({