From f708ea270f1587c8df8f51a21df70f9c665bc55e Mon Sep 17 00:00:00 2001 From: Jakub Pawlowicz Date: Fri, 16 Dec 2011 21:51:23 +0100 Subject: [PATCH] Fixed cleaning up '0 0 0 0.5em'. --- lib/clean.js | 2 +- test/unit-test.js | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/clean.js b/lib/clean.js index 95cc758a..ce7f6373 100644 --- a/lib/clean.js +++ b/lib/clean.js @@ -105,7 +105,7 @@ var CleanCSS = { replace(/(\s|:)0(px|em|ex|cm|mm|in|pt|pc|%)/g, '$1' + '0') // zero + unit to zero replace(/(border|border-top|border-right|border-bottom|border-left|outline):none/g, '$1:0') // none to 0 replace(/(background):none([;}])/g, '$1:0$2') // background:none to 0 - replace(/0 0 0 0/g, '0') // multiple zeros into one + replace(/0 0 0 0([^\.])/g, '0$1') // multiple zeros into one replace(/([: ,=\-])0\.(\d)/g, '$1.$2') replace(/[^\}]+{(;)*}/g, '') // empty elements if (data.indexOf('charset') > 0) replace(/(.+)(@charset [^;]+;)/, '$2$1') // move first charset to the beginning diff --git a/test/unit-test.js b/test/unit-test.js index 59b2fa90..04b921db 100644 --- a/test/unit-test.js +++ b/test/unit-test.js @@ -198,7 +198,16 @@ vows.describe('clean-units').addBatch({ 'display:none not changed': 'a{display:none}', 'longer background declaration not changed': 'html{background:none repeat scroll 0 0 white}', 'mixed zeros not changed': 'div{margin:0 0 1px 0}', - 'mixed zeros not changed #2': 'div{padding:0 1px 0 0}' + 'mixed zeros not changed #2': 'div{padding:0 1px 0 0}', + 'mixed zeros not changed #3': 'div{padding:10px 0 0 0}', + 'multiple zeros with fractions #1': [ + 'div{padding:0 0 0 0.5em}', + 'div{padding:0 0 0 .5em}' + ], + 'multiple zeros with fractions #2': [ + 'div{padding:0 0 0 .5em}', + 'div{padding:0 0 0 .5em}' + ] }), 'floats': cssContext({ 'strips zero in fractions': [ -- 2.34.1