From d0dae96139a83761ece79072f65b7d54976b6338 Mon Sep 17 00:00:00 2001 From: GoalSmashers Date: Sun, 3 Nov 2013 13:08:24 +0100 Subject: [PATCH] Fixes #167 - `background:transparent` minification. * It is safe to make it `background:0 0`. --- History.md | 1 + lib/clean.js | 2 +- test/data/big-min.css | 4 ++-- test/unit-test.js | 4 ++++ 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/History.md b/History.md index 5c943070..988374be 100644 --- a/History.md +++ b/History.md @@ -7,6 +7,7 @@ * Fixed issue [#157](https://github.com/GoalSmashers/clean-css/issues/157) - gets rid of `removeEmpty` option. * Fixed issue [#159](https://github.com/GoalSmashers/clean-css/issues/159) - escaped quotes inside content. * Fixed issue [#162](https://github.com/GoalSmashers/clean-css/issues/162) - strip quotes from base64 encoded URLs. +* Fixed issue [#167](https://github.com/GoalSmashers/clean-css/issues/167) - `background:transparent` minification. * Adds CSS tokenizer which will make it possible to optimize content by reordering and/or merging selectors. * Adds basic optimizer removing duplicate selectors from a list. * Adds merging duplicate properties within a single selector's body. diff --git a/lib/clean.js b/lib/clean.js index ab7084a7..cb170481 100644 --- a/lib/clean.js +++ b/lib/clean.js @@ -224,7 +224,7 @@ var CleanCSS = { replace(/(border|border-top|border-right|border-bottom|border-left|outline):none/g, '$1:0'); // background:none to background:0 0 - replace(/background:none([;}])/g, 'background:0 0$1'); + replace(/background:(?:none|transparent)([;}])/g, 'background:0 0$1'); // multiple zeros into one replace(/box-shadow:0 0 0 0([^\.])/g, 'box-shadow:0 0$1'); diff --git a/test/data/big-min.css b/test/data/big-min.css index 70d40ef7..e2b184bd 100644 --- a/test/data/big-min.css +++ b/test/data/big-min.css @@ -977,7 +977,7 @@ label i{font-style:normal;display:none} .liste_reactions .grid_9{width:424px} .liste_reactions .reaction:hover{background:#f5f8f9} .liste_reactions .premier{color:#a2a9ae;font-weight:700} -.liste_reactions .premier:hover{background:transparent} +.liste_reactions .premier:hover{background:0 0} .liste_reactions .reaction .btn{visibility:hidden;margin:5px 0 0} .liste_reactions .reaction:hover .btn{visibility:visible} .infobulle{position:relative} @@ -2983,4 +2983,4 @@ html.js body.dummy div#mainContent div#core-liberation div.col9 div.block div.bl html.js body.dummy div#mainContent div#core-liberation div.col9 div.block div.block-content div.favorites-frontpages div.col-left div.cartridge{width:388px} html.js body.dummy div#mainContent div#core-liberation div.col9 div.block div.block-content div.favorites-folders div.block-call-items div.block-content div.mini-tpl div.cartridge{margin-left:0;width:129px} html.js body.dummy div#mainContent div#core-liberation div.col7 div.block-call-items div.block-content div.mini-tpl div.folder-on-demand div.object-content{margin-right:0;min-height:0;border-bottom:0} -html.js body.dummy div#mainContent div#core-liberation div.col7 div.block-call-items div.block-content div.mini-tpl div.folder-on-demand{border-bottom:1px solid #E7E7E7} \ No newline at end of file +html.js body.dummy div#mainContent div#core-liberation div.col7 div.block-call-items div.block-content div.mini-tpl div.folder-on-demand{border-bottom:1px solid #E7E7E7} diff --git a/test/unit-test.js b/test/unit-test.js index e97de433..50543861 100644 --- a/test/unit-test.js +++ b/test/unit-test.js @@ -352,6 +352,10 @@ vows.describe('clean-units').addBatch({ 'a{border:none;background:none}', 'a{border:0;background:0 0}' ], + 'background:transparent to zero': [ + 'a{background:transparent}p{background transparent url(logo.png)}', + 'a{background:0 0}p{background transparent url(logo.png)}' + ], 'outline:none to outline:0': [ 'a{outline:none}', 'a{outline:0}' -- 2.34.1