Fixes #561 - restructuring special selectors.
authorJakub Pawlowicz <contact@jakubpawlowicz.com>
Mon, 4 May 2015 15:13:56 +0000 (16:13 +0100)
committerJakub Pawlowicz <contact@jakubpawlowicz.com>
Mon, 4 May 2015 15:18:41 +0000 (16:18 +0100)
Regression from v3.2.7 where we forgot to check if selectors are
special or not. See a fix to #551.

History.md
lib/selectors/optimizers/advanced.js
test/fixtures/big-min.css
test/selectors/optimizer-test.js

index 584d7d8..0d088d1 100644 (file)
 * Fixed issue [#517](https://github.com/jakubpawlowicz/clean-css/issues/517) - turning off color optimizations.
 * Fixed issue [#542](https://github.com/jakubpawlowicz/clean-css/issues/542) - space after closing brace in IE.
 
+[3.2.8 / 2015-xx-xx](https://github.com/jakubpawlowicz/clean-css/compare/v3.2.7...3.2)
+==================
+
+* Fixed issue [#561](https://github.com/jakubpawlowicz/clean-css/issues/561) - restructuring special selectors.
+
 [3.2.7 / 2015-05-03](https://github.com/jakubpawlowicz/clean-css/compare/v3.2.6...v3.2.7)
 ==================
 
index d20c8c4..89ce48c 100644 (file)
@@ -512,15 +512,18 @@ AdvancedOptimizer.prototype.restructure = function (tokens) {
     var candidates = [];
     var propertiesAndMergableTokens = [];
     var key = movedProperty[4];
-    var tokensToShorten = movableTokens[key];
     var j, k;
 
+    var mergeableTokens = tokensToMerge(movableTokens[key]);
+    if (mergeableTokens.length < 2)
+      return;
+
     movableLoop:
     for (var value in movableTokens) {
       var tokensList = movableTokens[value];
 
-      for (j = tokensToShorten.length - 1; j >= 0; j--) {
-        if (tokensList.indexOf(tokensToShorten[j]) == -1)
+      for (j = mergeableTokens.length - 1; j >= 0; j--) {
+        if (tokensList.indexOf(mergeableTokens[j]) == -1)
           continue movableLoop;
       }
 
@@ -533,7 +536,7 @@ AdvancedOptimizer.prototype.restructure = function (tokens) {
     for (j = candidates.length - 1; j >= 0; j--) {
       for (k = movedProperties.length - 1; k >= 0; k--) {
         if (movedProperties[k][4] == candidates[j]) {
-          propertiesAndMergableTokens.unshift([movedProperties[k], tokensToShorten]);
+          propertiesAndMergableTokens.unshift([movedProperties[k], mergeableTokens]);
           break;
         }
       }
index d4ce7f6..05b72f5 100644 (file)
@@ -1,6 +1,5 @@
 /*! normalize.css 2012-01-31T16:06 UTC - http://github.com/necolas/normalize.css */
 small,sub,sup{font-size:75%}
-button::-moz-focus-inner,input::-moz-focus-inner,legend{border:0;padding:0}
 .alpha,.ie .une_normale .liste_carre_999.liste_une .ie_impair,.liste_carre_999.liste_une li:nth-child(2n+3){clear:left}
 article,aside,details,figcaption,figure,footer,header,hgroup,nav,section{display:block}
 audio,canvas,video{display:inline-block}
@@ -29,7 +28,7 @@ nav ol,nav ul{list-style:none}
 img{-ms-interpolation-mode:bicubic}
 svg:not(:root){overflow:hidden}
 fieldset{border:1px solid silver;margin:0 2px;padding:.35em .625em .75em}
-legend{white-space:normal}
+legend{border:0;padding:0;white-space:normal}
 button,input,select,textarea{font-size:100%;margin:0;vertical-align:baseline}
 button,input{line-height:normal}
 button,input[type=button],input[type=reset],input[type=submit]{cursor:pointer;-webkit-appearance:button}
@@ -38,6 +37,7 @@ button[disabled],input[disabled]{cursor:default}
 input[type=checkbox],input[type=radio]{box-sizing:border-box;padding:0}
 input[type=search]{-webkit-appearance:textfield;-moz-box-sizing:content-box;-webkit-box-sizing:content-box;box-sizing:content-box}
 input[type=search]::-webkit-search-cancel-button,input[type=search]::-webkit-search-decoration{-webkit-appearance:none}
+button::-moz-focus-inner,input::-moz-focus-inner{border:0;padding:0}
 textarea{overflow:auto;vertical-align:top}
 table{border-spacing:0;border-collapse:collapse}
 @font-face{font-family:TheSerifOffice;src:url(/medias/web/font/svg/TheSerifOffice-OT7_West.svgz#TheSerifOffice) format('svg');src:url(/medias/web/font/eot/TheSerifOffice-TT7_.eot);src:url(/medias/web/font/eot/TheSerifOffice-TT7_.eot?#iefix) format('embedded-opentype'),url(/medias/web/font/woff/TheSerifOffice-TT7_.woff) format('woff');font-weight:400;font-style:normal}
index 1e7a8fc..b20d3c8 100644 (file)
@@ -189,6 +189,10 @@ vows.describe(SelectorsOptimizer)
         '.one{background:red;padding:8px 16px}.two{padding-left:16px;padding-right:16px}.three{padding-top:20px}.four{border-left:1px solid #000;border-right:1px solid #000;border-bottom:1px solid #000}.five{background-color:#fff;background-image:-moz-linear-gradient();background-image:-ms-linear-gradient();background-image:-webkit-gradient();background-image:-webkit-linear-gradient()}',
         '.one{background:red;padding:8px 16px}.two{padding-left:16px;padding-right:16px}.three{padding-top:20px}.four{border-left:1px solid #000;border-right:1px solid #000;border-bottom:1px solid #000}.five{background-color:#fff;background-image:-moz-linear-gradient();background-image:-ms-linear-gradient();background-image:-webkit-gradient();background-image:-webkit-linear-gradient()}'
       ],
+      'multiple granular - special': [
+        'input:-ms-input-placeholder{color:red;text-align:center}input::placeholder{color:red;text-align:center}',
+        'input:-ms-input-placeholder{color:red;text-align:center}input::placeholder{color:red;text-align:center}'
+      ],
       'moving one already being moved with different value': [
         '.one{color:red}.two{display:block}.three{color:red;display:inline}.four{display:inline-block}.five{color:#000}',
         '.one,.three{color:red}.two{display:block}.three{display:inline}.four{display:inline-block}.five{color:#000}'