From: silverwind Date: Mon, 26 Sep 2016 04:36:31 +0000 (+0200) Subject: Prevent rules with :selection from being merged (#814) X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=2b4462c69f834792f942a88f026fa7b500ee6c02;p=clean-css.git Prevent rules with :selection from being merged (#814) Firefox does not support :selection, only :-moz-selection. This change adds :selection to the list of problematic selectors to prevent invalid rules from being created. Also cleaned up the regex, : and :: are equivalent in this regex, so reduced all section to just :. --- diff --git a/lib/utils/compatibility.js b/lib/utils/compatibility.js index 25bb5311..112a6dcc 100644 --- a/lib/utils/compatibility.js +++ b/lib/utils/compatibility.js @@ -22,7 +22,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|:host|::content|\/deep\/|::shadow|^,)/ // 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|:selection|^,)/ // special selectors which prevent merging }, units: { ch: true, diff --git a/test/integration-test.js b/test/integration-test.js index c0fdceff..c422021f 100644 --- a/test/integration-test.js +++ b/test/integration-test.js @@ -2467,6 +2467,10 @@ vows.describe('integration tests') ':placeholder{color:red}b{color:red}', ':placeholder{color:red}b{color:red}' ], + 'rules with not-so-well-supported pseudo classes should not be merged #6': [ + ':selection{color:red}b{color:red}', + ':selection{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}'