From 16a6d02acbf0e5bad0d26bb6ec61d874d81bc8ca Mon Sep 17 00:00:00 2001 From: Jakub Pawlowicz Date: Sun, 27 Nov 2011 16:01:02 +0100 Subject: [PATCH] Fixed expanding + signs in calc() when mixed up with adjacent (+) selector. --- lib/clean.js | 2 +- test/unit-test.js | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/clean.js b/lib/clean.js index 425b343f..0bc0dfe7 100644 --- a/lib/clean.js +++ b/lib/clean.js @@ -115,7 +115,7 @@ var CleanCSS = { replace(/\} /g, '}') // whitespace after definition // Get the special comments, content content, and spaces inside calc back - replace(/calc\((.+)\)([;\}\w])/, function(match) { + replace(/calc\([^\}]+\}/g, function(match) { return match.replace(/\+/g, ' + '); }); replace(/__CSSCOMMENT__/g, function() { return specialComments.shift(); }); diff --git a/test/unit-test.js b/test/unit-test.js index be02e8db..59b2fa90 100644 --- a/test/unit-test.js +++ b/test/unit-test.js @@ -131,6 +131,10 @@ vows.describe('clean-units').addBatch({ 'not strip standalone universal selector': [ 'label ~ * + span', 'label~*+span' + ], + 'not expand + in selectors mixed with calc methods': [ + 'div{width:calc(50% + 3em)}div + div{width:100%}div:hover{width:calc(50% + 4em)}* > div {border:1px solid #f0f}', + 'div{width:calc(50% + 3em)}div+div{width:100%}div:hover{width:calc(50% + 4em)}*>div{border:1px solid #f0f}' ] }), 'comments': cssContext({ -- 2.34.1