From: Jakub Pawlowicz Date: Mon, 24 Aug 2015 04:36:30 +0000 (+0100) Subject: Adds support for Polymer / Web Components selectors. X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=de1c3fa2c677140809ed3c8fd95f2d0bd832de4a;p=clean-css.git Adds support for Polymer / Web Components selectors. These include * :host and ::content for Polymer * /deep/ and ::shadow for Web Components See #648. --- diff --git a/History.md b/History.md index a2781efc..2d6946da 100644 --- a/History.md +++ b/History.md @@ -3,6 +3,7 @@ * Adds unit compatibility switches to disable length optimizations. * Adds inferring proxy settings from HTTP_PROXY environment variable. +* Adds support for Polymer / Web Components special selectors. * Unifies wrappers for simple & advanced optimizations. * Fixed issue [#596](https://github.com/jakubpawlowicz/clean-css/issues/596) - support for !ie IE<8 hack. * Fixed issue [#599](https://github.com/jakubpawlowicz/clean-css/issues/599) - support for inlined source maps. diff --git a/lib/utils/compatibility.js b/lib/utils/compatibility.js index 1f8aecb3..34a82699 100644 --- a/lib/utils/compatibility.js +++ b/lib/utils/compatibility.js @@ -21,7 +21,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|:placeholder)/ // special selectors which prevent merging + special: /(\-moz\-|\-ms\-|\-o\-|\-webkit\-|:dir\([a-z-]*\)|:first(?![a-z-])|:fullscreen|:left|:read-only|:read-write|:right|:placeholder|:host|::content|\/deep\/|::shadow)/ // special selectors which prevent merging }, units: { ch: true, @@ -56,7 +56,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|:placeholder)/ + special: /(\-moz\-|\-ms\-|\-o\-|\-webkit\-|:root|:nth|:first\-of|:last|:only|:empty|:target|:checked|::selection|:enabled|:disabled|:not|:placeholder|:host|::content|\/deep\/|::shadow)/ }, units: { ch: false, @@ -91,7 +91,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|:placeholder)/ + special: /(\-moz\-|\-ms\-|\-o\-|\-webkit\-|:focus|:before|:after|:root|:nth|:first\-of|:last|:only|:empty|:target|:checked|::selection|:enabled|:disabled|:not|:placeholder|:host|::content|\/deep\/|::shadow)/ }, units: { ch: false, diff --git a/test/integration-test.js b/test/integration-test.js index 7212901b..b6ec0b5b 100644 --- a/test/integration-test.js +++ b/test/integration-test.js @@ -2379,6 +2379,22 @@ vows.describe('integration tests') '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}' + ], + 'rules with :host Polymer pseudo class should not be merged into': [ + ':host{color:red}b{color:red}', + ':host{color:red}b{color:red}' + ], + 'rules with ::content Polymer pseudo element should not be merged into': [ + '.wrapper ::content a{color:red}b{color:red}', + '.wrapper ::content a{color:red}b{color:red}' + ], + 'rules with /deep/ Polymer combinator not be merged into': [ + '.wrapper /deep/ a{color:red}b{color:red}', + '.wrapper /deep/ a{color:red}b{color:red}' + ], + 'rules with ::shadow Polymer combinator not be merged into': [ + '.wrapper ::shadow a{color:red}b{color:red}', + '.wrapper ::shadow a{color:red}b{color:red}' ] }) )