Fixes #634 - merging :placeholder selectors.
authorJakub Pawlowicz <contact@jakubpawlowicz.com>
Thu, 6 Aug 2015 08:14:30 +0000 (09:14 +0100)
committerJakub Pawlowicz <contact@jakubpawlowicz.com>
Thu, 6 Aug 2015 08:41:13 +0000 (09:41 +0100)
:placeholder is also not widely supported (IE10+) so we need to
skip merging it.

History.md
lib/utils/compatibility.js
test/integration-test.js
test/utils/compatibility-test.js

index c053ea6..4faf228 100644 (file)
@@ -10,6 +10,7 @@
 * Fixed issue [#629](https://github.com/jakubpawlowicz/clean-css/issues/629) - source maps & background shorthands.
 * Fixed issue [#630](https://github.com/jakubpawlowicz/clean-css/issues/630) - vendor prefixed flex optimizations.
 * Fixed issue [#633](https://github.com/jakubpawlowicz/clean-css/issues/633) - handling data URI with brackets.
+* Fixed issue [#634](https://github.com/jakubpawlowicz/clean-css/issues/634) - merging :placeholder selectors.
 
 [3.3.7 / 2015-07-29](https://github.com/jakubpawlowicz/clean-css/compare/v3.3.6...v3.3.7)
 ==================
index 2594d01..66892a9 100644 (file)
@@ -20,7 +20,7 @@ var DEFAULTS = {
     selectors: {
       adjacentSpace: false, // div+ nav Android stock browser hack
       ie7Hack: false, // *+html hack
-      special: /(\-moz\-|\-ms\-|\-o\-|\-webkit\-|:dir\([a-z-]*\)|:first(?![a-z-])|:fullscreen|:left|:read-only|:read-write|:right)/ // special selectors which prevent merging
+      special: /(\-moz\-|\-ms\-|\-o\-|\-webkit\-|:dir\([a-z-]*\)|:first(?![a-z-])|:fullscreen|:left|:read-only|:read-write|:right|:placeholder)/ // special selectors which prevent merging
     },
     units: {
       ch: true,
@@ -51,7 +51,7 @@ var DEFAULTS = {
     selectors: {
       adjacentSpace: false,
       ie7Hack: false,
-      special: /(\-moz\-|\-ms\-|\-o\-|\-webkit\-|:root|:nth|:first\-of|:last|:only|:empty|:target|:checked|::selection|:enabled|:disabled|:not)/
+      special: /(\-moz\-|\-ms\-|\-o\-|\-webkit\-|:root|:nth|:first\-of|:last|:only|:empty|:target|:checked|::selection|:enabled|:disabled|:not|:placeholder)/
     },
     units: {
       ch: false,
@@ -82,7 +82,7 @@ var DEFAULTS = {
     selectors: {
       adjacentSpace: false,
       ie7Hack: true,
-      special: /(\-moz\-|\-ms\-|\-o\-|\-webkit\-|:focus|:before|:after|:root|:nth|:first\-of|:last|:only|:empty|:target|:checked|::selection|:enabled|:disabled|:not)/
+      special: /(\-moz\-|\-ms\-|\-o\-|\-webkit\-|:focus|:before|:after|:root|:nth|:first\-of|:last|:only|:empty|:target|:checked|::selection|:enabled|:disabled|:not|:placeholder)/
     },
     units: {
       ch: false,
index 59a3b27..4585524 100644 (file)
@@ -2343,6 +2343,10 @@ vows.describe('integration tests')
       'rules with not-so-well-supported pseudo classes should not be merged #4': [
         'a:first{color:red}b{color:red}',
         'a:first{color:red}b{color:red}'
+      ],
+      'rules with not-so-well-supported pseudo classes should not be merged #5': [
+        ':placeholder{color:red}b{color:red}',
+        ':placeholder{color:red}b{color:red}'
       ]
     })
   )
index 1a92662..2b98d59 100644 (file)
@@ -22,7 +22,6 @@ vows.describe(Compatibility)
         assert.isTrue(options.properties.zeroUnits);
         assert.isFalse(options.selectors.adjacentSpace);
         assert.isFalse(options.selectors.ie7Hack);
-        assert.deepEqual(options.selectors.special, /(\-moz\-|\-ms\-|\-o\-|\-webkit\-|:dir\([a-z-]*\)|:first(?![a-z-])|:fullscreen|:left|:read-only|:read-write|:right)/);
         assert.isTrue(options.units.ch);
         assert.isTrue(options.units.rem);
         assert.isTrue(options.units.vh);
@@ -57,7 +56,6 @@ vows.describe(Compatibility)
         assert.isTrue(options.properties.zeroUnits);
         assert.isFalse(options.selectors.adjacentSpace);
         assert.isFalse(options.selectors.ie7Hack);
-        assert.deepEqual(options.selectors.special, /(\-moz\-|\-ms\-|\-o\-|\-webkit\-|:dir\([a-z-]*\)|:first(?![a-z-])|:fullscreen|:left|:read-only|:read-write|:right)/);
         assert.isTrue(options.units.ch);
         assert.isFalse(options.units.rem);
         assert.isTrue(options.units.vh);
@@ -87,7 +85,6 @@ vows.describe(Compatibility)
         assert.isTrue(options.properties.zeroUnits);
         assert.isFalse(options.selectors.adjacentSpace);
         assert.isFalse(options.selectors.ie7Hack);
-        assert.deepEqual(options.selectors.special, /(\-moz\-|\-ms\-|\-o\-|\-webkit\-|:root|:nth|:first\-of|:last|:only|:empty|:target|:checked|::selection|:enabled|:disabled|:not)/);
         assert.isFalse(options.units.ch);
         assert.isFalse(options.units.rem);
         assert.isFalse(options.units.vh);
@@ -115,7 +112,6 @@ vows.describe(Compatibility)
         assert.isTrue(options.properties.zeroUnits);
         assert.isFalse(options.selectors.adjacentSpace);
         assert.isTrue(options.selectors.ie7Hack);
-        assert.deepEqual(options.selectors.special, /(\-moz\-|\-ms\-|\-o\-|\-webkit\-|:focus|:before|:after|:root|:nth|:first\-of|:last|:only|:empty|:target|:checked|::selection|:enabled|:disabled|:not)/);
         assert.isFalse(options.units.ch);
         assert.isFalse(options.units.rem);
         assert.isFalse(options.units.vh);
@@ -153,7 +149,6 @@ vows.describe(Compatibility)
         assert.isTrue(options.properties.zeroUnits);
         assert.isFalse(options.selectors.adjacentSpace);
         assert.isFalse(options.selectors.ie7Hack);
-        assert.deepEqual(options.selectors.special, /(\-moz\-|\-ms\-|\-o\-|\-webkit\-|:root|:nth|:first\-of|:last|:only|:empty|:target|:checked|::selection|:enabled|:disabled|:not)/);
         assert.isFalse(options.units.ch);
         assert.isFalse(options.units.rem);
         assert.isFalse(options.units.vh);
@@ -181,7 +176,6 @@ vows.describe(Compatibility)
         assert.isTrue(options.properties.zeroUnits);
         assert.isFalse(options.selectors.adjacentSpace);
         assert.isFalse(options.selectors.ie7Hack);
-        assert.deepEqual(options.selectors.special, /(\-moz\-|\-ms\-|\-o\-|\-webkit\-|:dir\([a-z-]*\)|:first(?![a-z-])|:fullscreen|:left|:read-only|:read-write|:right)/);
         assert.isTrue(options.units.ch);
         assert.isTrue(options.units.rem);
         assert.isTrue(options.units.vh);
@@ -209,7 +203,6 @@ vows.describe(Compatibility)
         assert.isTrue(options.properties.zeroUnits);
         assert.isFalse(options.selectors.adjacentSpace);
         assert.isFalse(options.selectors.ie7Hack);
-        assert.deepEqual(options.selectors.special, /(\-moz\-|\-ms\-|\-o\-|\-webkit\-|:dir\([a-z-]*\)|:first(?![a-z-])|:fullscreen|:left|:read-only|:read-write|:right)/);
         assert.isTrue(options.units.ch);
         assert.isFalse(options.units.rem);
         assert.isTrue(options.units.vh);