From 224cc692699670411bb81672a0c1081feb63ab29 Mon Sep 17 00:00:00 2001 From: Jakub Pawlowicz Date: Thu, 5 Nov 2015 08:16:14 +0000 Subject: [PATCH] Fixes #699 - IE9 transparent hack. There is a Explorer 9 hack requiring `rgba(0,0,0,0)` not a minified `transparent` value for `background` property. --- History.md | 1 + lib/selectors/simple.js | 4 ++-- test/fixtures/bootstrap-min.css | 2 +- test/integration-test.js | 10 +++++++++- 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/History.md b/History.md index e09607f2..fe9ac292 100644 --- a/History.md +++ b/History.md @@ -7,6 +7,7 @@ ================== * Fixed issue [#695](https://github.com/jakubpawlowicz/clean-css/issues/695) - shorthand overriding edge case. +* Fixed issue [#699](https://github.com/jakubpawlowicz/clean-css/issues/699) - IE9 transparent hack. [3.4.6 / 2015-10-14](https://github.com/jakubpawlowicz/clean-css/compare/v3.4.5...v3.4.6) ================== diff --git a/lib/selectors/simple.js b/lib/selectors/simple.js index c1265140..75490554 100644 --- a/lib/selectors/simple.js +++ b/lib/selectors/simple.js @@ -128,7 +128,7 @@ function multipleZerosMinifier(property) { } } -function colorMininifier(_, value, compatibility) { +function colorMininifier(name, value, compatibility) { if (value.indexOf('#') === -1 && value.indexOf('rgb') == -1 && value.indexOf('hsl') == -1) return HexNameShortener.shorten(value); @@ -161,7 +161,7 @@ function colorMininifier(_, value, compatibility) { return colorFunction + '(' + tokens.join(',') + ')'; }); - if (compatibility.colors.opacity) { + if (compatibility.colors.opacity && name.indexOf('background') == -1) { value = value.replace(/(?:rgba|hsla)\(0,0%?,0%?,0\)/g, function (match) { if (split(value, ',').pop().indexOf('gradient(') > -1) return match; diff --git a/test/fixtures/bootstrap-min.css b/test/fixtures/bootstrap-min.css index d19f3f99..7ab38890 100644 --- a/test/fixtures/bootstrap-min.css +++ b/test/fixtures/bootstrap-min.css @@ -1345,7 +1345,7 @@ button.close{-webkit-appearance:none;padding:0;cursor:pointer;background:0 0;bor .carousel-control .icon-prev:before{content:'\2039'} .carousel-control .icon-next:before{content:'\203a'} .carousel-indicators{position:absolute;bottom:10px;left:50%;z-index:15;width:60%;padding-left:0;margin-left:-30%;text-align:center;list-style:none} -.carousel-indicators li{display:inline-block;width:10px;height:10px;margin:1px;text-indent:-999px;cursor:pointer;background-color:#000\9;background-color:transparent;border:1px solid #fff;border-radius:10px} +.carousel-indicators li{display:inline-block;width:10px;height:10px;margin:1px;text-indent:-999px;cursor:pointer;background-color:#000\9;background-color:rgba(0,0,0,0);border:1px solid #fff;border-radius:10px} .carousel-indicators .active{width:12px;height:12px;margin:0;background-color:#fff} .carousel-caption{position:absolute;right:15%;bottom:20px;left:15%;z-index:10;padding-top:20px;padding-bottom:20px;color:#fff;text-align:center;text-shadow:0 1px 2px rgba(0,0,0,.6)} .carousel-caption .btn,.text-hide{text-shadow:none} diff --git a/test/integration-test.js b/test/integration-test.js index ec74d1fb..b99cad49 100644 --- a/test/integration-test.js +++ b/test/integration-test.js @@ -1119,6 +1119,14 @@ vows.describe('integration tests') 'a{color:hsla(0.0,0.0,0.0,0)}', 'a{color:transparent}' ], + 'keeps rgba(0,0,0,0) for background': [ + 'a{background:rgba(0,0,0,0)}', + 'a{background:rgba(0,0,0,0)}' + ], + 'keeps rgba(0,0,0,0) for background-color': [ + 'a{background-color:rgba(0,0,0,0)}', + 'a{background-color:rgba(0,0,0,0)}' + ], 'keeps rgba(255,255,255,0)': [ 'a{color:rgba(255,255,255,0)}', 'a{color:rgba(255,255,255,0)}' @@ -1153,7 +1161,7 @@ vows.describe('integration tests') ], 'removes only right transparent colors': [ 'a{background-color:linear-gradient(0,#000,hsla(120,100%,50%,0)),rgba(0,0,0,0)}', - 'a{background-color:linear-gradient(0,#000,hsla(120,100%,50%,0)),transparent}' + 'a{background-color:linear-gradient(0,#000,hsla(120,100%,50%,0)),rgba(0,0,0,0)}' ] }) ) -- 2.34.1