Fixed #828 - `-chrome-` hack support.
authorJakub Pawlowicz <contact@jakubpawlowicz.com>
Wed, 4 Jan 2017 21:22:05 +0000 (22:22 +0100)
committerJakub Pawlowicz <contact@jakubpawlowicz.com>
Wed, 4 Jan 2017 21:22:05 +0000 (22:22 +0100)
Why:

* It was incorrectly handled by property extractor.

History.md
lib/optimizer/basic.js
lib/optimizer/extract-properties.js
test/fixtures/issue-828-min.css [new file with mode: 0644]
test/fixtures/issue-828.css [new file with mode: 0644]

index fc74761..2ef97ec 100644 (file)
@@ -29,6 +29,7 @@
 * Fixed issue [#806](https://github.com/jakubpawlowicz/clean-css/issues/806) - skip optimizing variable properties.
 * Fixed issue [#817](https://github.com/jakubpawlowicz/clean-css/issues/817) - makes `off` disable rounding.
 * Fixed issue [#818](https://github.com/jakubpawlowicz/clean-css/issues/818) - disables `px` rounding by default.
+* Fixed issue [#828](https://github.com/jakubpawlowicz/clean-css/issues/828) - `-chrome-` hack support.
 * Fixed issue [#829](https://github.com/jakubpawlowicz/clean-css/issues/829) - adds more strict selector merging rules.
 * Fixed issue [#834](https://github.com/jakubpawlowicz/clean-css/issues/834) - adds extra line break in nested blocks.
 * Fixed issue [#839](https://github.com/jakubpawlowicz/clean-css/issues/839) - allows URIs in import inlining rules.
index fd98b09..45b7aec 100644 (file)
@@ -98,8 +98,8 @@ function whitespaceMinifier(name, value) {
     value = value.replace(/\) ?\/ ?/g, ')/ ');
 
   return value
-    .replace(/\( /g, '(')
-    .replace(/ \)/g, ')')
+    .replace(/(\(;?)\s+/g, '$1')
+    .replace(/\s+(;?\))/g, '$1')
     .replace(/, /g, ',');
 }
 
index 93d49ca..1fbd309 100644 (file)
@@ -64,6 +64,8 @@ function findNameRoot(name) {
     return 'border';
   if (name.indexOf('text-') === 0)
     return name;
+  if (name == '-chrome-')
+    return name;
 
   return name.replace(/^\-\w+\-/, '').match(/([a-zA-Z]+)/)[0].toLowerCase();
 }
diff --git a/test/fixtures/issue-828-min.css b/test/fixtures/issue-828-min.css
new file mode 100644 (file)
index 0000000..b76e15e
--- /dev/null
@@ -0,0 +1,3 @@
+@media screen and(-webkit-min-device-pixel-ratio:0){
+.logo img{-chrome-:only(;image-rendering:-webkit-optimize-contrast;)}
+}
diff --git a/test/fixtures/issue-828.css b/test/fixtures/issue-828.css
new file mode 100644 (file)
index 0000000..2ce2473
--- /dev/null
@@ -0,0 +1,5 @@
+@media screen and(-webkit-min-device-pixel-ratio:0) {
+  .logo img{-chrome-:only(;
+     image-rendering:-webkit-optimize-contrast;
+  );}
+}