Adds a full list of unsupported selectors on IE7 and IE8.
authorJakub Pawlowicz <jakub@goalsmashers.com>
Mon, 10 Feb 2014 22:18:40 +0000 (22:18 +0000)
committerJakub Pawlowicz <jakub@goalsmashers.com>
Mon, 10 Feb 2014 22:18:40 +0000 (22:18 +0000)
Makes sure we don't merge all unsupported selectors as per list at:
http://kimblim.dk/css-tests/selectors/

lib/selectors/optimizer.js
test/binary-test.js
test/data/unsupported/selectors-ie7.css [new file with mode: 0644]
test/data/unsupported/selectors-ie8.css [new file with mode: 0644]

index 38950fa..df1c867 100644 (file)
@@ -4,8 +4,8 @@ var PropertyOptimizer = require('../properties/optimizer');
 module.exports = function Optimizer(data, context, options) {
   var specialSelectors = {
     '*': /\-(moz|ms|o|webkit)\-/,
-    'ie8': /(\-moz\-|\-ms\-|\-o\-|\-webkit\-|:not|:target|:visited|:empty|:first\-of|:last|:nth|:only|:root)/,
-    'ie7': /(\-moz\-|\-ms\-|\-o\-|\-webkit\-|:not|:target|:visited|:empty|:first\-of|:last|:nth|:only|:root|:after|:before|:focus)/
+    'ie8': /(\-moz\-|\-ms\-|\-o\-|\-webkit\-|:root|:nth|:first\-of|:last|:only|:empty|:target|:checked|::selection|:enabled|:disabled|:not)/,
+    'ie7': /(\-moz\-|\-ms\-|\-o\-|\-webkit\-|:focus|:before|:after|:root|:nth|:first\-of|:last|:only|:empty|:target|:checked|::selection|:enabled|:disabled|:not)/
   };
 
   var minificationsMade = [];
index 4663521..a11f476 100644 (file)
@@ -256,5 +256,15 @@ exports.commandsSuite = vows.describe('binary commands').addBatch({
     teardown: function() {
       this.server.close();
     }
+  }),
+  'ie7 compatibility': binaryContext('--compatibility ie7 ./test/data/unsupported/selectors-ie7.css', {
+    'should not transform source': function(error, stdout) {
+      assert.equal(stdout, readFile('./test/data/unsupported/selectors-ie7.css'));
+    }
+  }),
+  'ie8 compatibility': binaryContext('--compatibility ie8 ./test/data/unsupported/selectors-ie8.css', {
+    'should not transform source': function(error, stdout) {
+      assert.equal(stdout, readFile('./test/data/unsupported/selectors-ie8.css'));
+    }
   })
 });
diff --git a/test/data/unsupported/selectors-ie7.css b/test/data/unsupported/selectors-ie7.css
new file mode 100644 (file)
index 0000000..3f2fc3e
--- /dev/null
@@ -0,0 +1,20 @@
+p:focus{top:0}
+p:before{top:0}
+p:after{top:0}
+p:root{top:0}
+p:nth-of-type(1){top:0}
+p:nth-last-of-type(1){top:0}
+p:first-of-type{top:0}
+p:last-of-type{top:0}
+p:only-of-type{top:0}
+p:only-child{top:0}
+p:last-child{top:0}
+p:nth-child(1){top:0}
+p:nth-last-child(1){top:0}
+p:empty{top:0}
+p:target{top:0}
+p:checked{top:0}
+p::selection{top:0}
+input:enabled{top:0}
+input:disabled{top:0}
+p:not(.x){top:0}
diff --git a/test/data/unsupported/selectors-ie8.css b/test/data/unsupported/selectors-ie8.css
new file mode 100644 (file)
index 0000000..2d01251
--- /dev/null
@@ -0,0 +1,17 @@
+p:root{top:0}
+p:nth-of-type(1){top:0}
+p:nth-last-of-type(1){top:0}
+p:first-of-type{top:0}
+p:last-of-type{top:0}
+p:only-of-type{top:0}
+p:only-child{top:0}
+p:last-child{top:0}
+p:nth-child(1){top:0}
+p:nth-last-child(1){top:0}
+p:empty{top:0}
+p:target{top:0}
+p:checked{top:0}
+p::selection{top:0}
+input:enabled{top:0}
+input:disabled{top:0}
+p:not(.x){top:0}