From 3f3dc8d5e47bd9a6709ee5ebe4ecfa4c2a1dd52b Mon Sep 17 00:00:00 2001 From: Jakub Pawlowicz Date: Sat, 14 Jun 2014 09:25:47 +0100 Subject: [PATCH] Fixes #294 - space after rgba/hsla is required in IE<=11. * #165 introduced the bug. --- History.md | 1 + lib/clean.js | 3 --- lib/properties/processable.js | 7 +++++-- test/unit-test.js | 10 ++-------- 4 files changed, 8 insertions(+), 13 deletions(-) diff --git a/History.md b/History.md index 3634e51a..10adbf32 100644 --- a/History.md +++ b/History.md @@ -2,6 +2,7 @@ ================== * Fixes new property optimizer for 'none' values. +* Fixed issue [#294](https://github.com/GoalSmashers/clean-css/issues/294) - space after rgba/hsla in IE<=11. [2.2.0 / 2014-06-11](https://github.com/GoalSmashers/clean-css/compare/v2.1.8...2.2.0) ================== diff --git a/lib/clean.js b/lib/clean.js index bc4bb392..d4e00288 100644 --- a/lib/clean.js +++ b/lib/clean.js @@ -328,9 +328,6 @@ var minify = function(data, callback) { return match.replace(/\+/g, ' + '); }); - // remove space after (rgba|hsla) declaration - see #165 - replace(/(rgba|hsla)\(([^\)]+)\) /g, '$1($2)'); - // get rid of IE hacks if not in compatibility mode if (!options.compatibility) replace(/([;\{])[\*_][\w\-]+:[^;\}]+/g, '$1'); diff --git a/lib/properties/processable.js b/lib/properties/processable.js index c98b9eac..e1a0a59a 100644 --- a/lib/properties/processable.js +++ b/lib/properties/processable.js @@ -161,8 +161,11 @@ module.exports = (function () { curr = ''; } } else if (c === ' ' && parenthesisLevel === 0) { - result.push(curr.trim()); - curr = ''; + curr = curr.trim(); + if (curr !== '') { + result.push(curr); + curr = ''; + } } } diff --git a/test/unit-test.js b/test/unit-test.js index bd8682bd..298e4d0f 100644 --- a/test/unit-test.js +++ b/test/unit-test.js @@ -182,18 +182,12 @@ vows.describe('clean-units').addBatch({ 'a{text-shadow:rgb(255,0,1) 1px 1px}', 'a{text-shadow:#ff0001 1px 1px}' ], - 'after rgba': [ - 'a{text-shadow:rgba(255,0,0,1) 0 1px}', - 'a{text-shadow:rgba(255,0,0,1)0 1px}' - ], + 'after rgba': 'a{text-shadow:rgba(255,0,0,1) 0 1px}', 'after hsl': [ 'a{text-shadow:hsl(240,100%,40%) -1px 1px}', 'a{text-shadow:#00c -1px 1px}' ], - 'after hsla': [ - 'a{text-shadow:hsla(240,100%,40%,.5) -1px 1px}', - 'a{text-shadow:hsla(240,100%,40%,.5)-1px 1px}' - ] + 'after hsla': 'a{text-shadow:hsla(240,100%,40%,.5) -1px 1px}' }), 'line breaks': cssContext({ 'line breaks': [ -- 2.34.1