Fixes #602 - backslash IE hacks after a space.
authorJakub Pawlowicz <contact@jakubpawlowicz.com>
Sun, 14 Jun 2015 14:41:11 +0000 (15:41 +0100)
committerJakub Pawlowicz <contact@jakubpawlowicz.com>
Sun, 14 Jun 2015 14:56:53 +0000 (15:56 +0100)
Previously a backslash IE hacks with a leading space
were not processed correctly.

History.md
lib/selectors/optimization-metadata.js
test/fixtures/bootstrap-min.css
test/selectors/optimization-metadata-test.js

index 77f5452..4962dfa 100644 (file)
@@ -3,6 +3,7 @@
 
 * Fixed issue [#595](https://github.com/jakubpawlowicz/clean-css/issues/595) - more relaxed block matching.
 * Fixed issue [#601](https://github.com/jakubpawlowicz/clean-css/issues/601) - percentage minifying inside `flex`.
+* Fixed issue [#602](https://github.com/jakubpawlowicz/clean-css/issues/602) - backslash IE hacks after a space.
 
 [3.3.1 / 2015-06-02](https://github.com/jakubpawlowicz/clean-css/compare/v3.3.0...v3.3.1)
 ==================
index a0b27a8..566b9e3 100644 (file)
@@ -43,6 +43,9 @@ function addToProperty(property) {
   } else if (lastValue[0].indexOf(BACKSLASH_HACK) > 0 && lastValue[0].indexOf(BACKSLASH_HACK) == lastValue[0].length - BACKSLASH_HACK.length - 1) {
     lastValue[0] = lastValue[0].substring(0, lastValue[0].length - BACKSLASH_HACK.length - 1);
     hackType = 'suffix';
+  } else if (lastValue[0].indexOf(BACKSLASH_HACK) === 0 && lastValue[0].length == 2) {
+    property.pop();
+    hackType = 'suffix';
   }
 
   // TODO: this should be done at tokenization step
index fb357e4..0f2334f 100644 (file)
@@ -663,7 +663,7 @@ fieldset{min-width:0;margin:0}
 legend{display:block;width:100%;margin-bottom:20px;font-size:21px;line-height:inherit;color:#333;border-bottom:1px solid #e5e5e5}
 label{display:inline-block;max-width:100%;margin-bottom:5px}
 input[type=search]{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;-webkit-appearance:none}
-input[type=checkbox],input[type=radio]{margin:4px 0 0;margin-top:1px \9;line-height:normal}
+input[type=checkbox],input[type=radio]{margin:4px 0 0;line-height:normal}
 .form-control,output{display:block;font-size:14px;line-height:1.42857143;color:#555}
 input[type=file]{display:block}
 input[type=range]{display:block;width:100%}
@@ -686,7 +686,7 @@ textarea.form-control{height:auto}
 .form-group{margin-bottom:15px}
 .checkbox,.radio{position:relative;display:block;margin-top:10px;margin-bottom:10px}
 .checkbox label,.radio label{min-height:20px;padding-left:20px;margin-bottom:0;font-weight:400;cursor:pointer}
-.checkbox input[type=checkbox],.checkbox-inline input[type=checkbox],.radio input[type=radio],.radio-inline input[type=radio]{position:absolute;margin-top:4px \9;margin-left:-20px}
+.checkbox input[type=checkbox],.checkbox-inline input[type=checkbox],.radio input[type=radio],.radio-inline input[type=radio]{position:absolute;margin-left:-20px}
 .checkbox+.checkbox,.radio+.radio{margin-top:-5px}
 .checkbox-inline,.radio-inline{display:inline-block;padding-left:20px;margin-bottom:0;font-weight:400;vertical-align:middle;cursor:pointer}
 .checkbox-inline+.checkbox-inline,.radio-inline+.radio-inline{margin-top:0;margin-left:10px}
index fec289c..d8936ac 100644 (file)
@@ -60,6 +60,13 @@ vows.describe(addOptimizationMetadata)
         addOptimizationMetadata(tokens);
         assert.deepEqual(tokens, [['selector', ['a'], [[['width', false, false], ['0']]] ]]);
       }
+    },
+    'backslash hack - space between values123': {
+      'topic': [['selector', ['a'], [[['width'], ['0'], ['\\9']]] ]],
+      'metadata': function (tokens) {
+        addOptimizationMetadata(tokens);
+        assert.deepEqual(tokens, [['selector', ['a'], [[['width', false, 'suffix'], ['0']]] ]]);
+      }
     }
   })
   .addBatch({