From: GoalSmashers Date: Wed, 25 Dec 2013 10:00:44 +0000 (+0100) Subject: Fixes #199 - keeps line breaks if requested when advanced optimizations are off. X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=ab1de55fd897d59aa207757ff721e3782abf1dad;p=clean-css.git Fixes #199 - keeps line breaks if requested when advanced optimizations are off. --- diff --git a/History.md b/History.md index ed05013b..22283cf5 100644 --- a/History.md +++ b/History.md @@ -9,6 +9,11 @@ * Fixed issue [#165](https://github.com/GoalSmashers/clean-css/issues/165) - extra space after trailing parenthesis. * Fixed issue [#186](https://github.com/GoalSmashers/clean-css/issues/186) - strip unit from 0rem. +[2.0.5 / 2013-xx-xx (UNRELEASED)](https://github.com/GoalSmashers/clean-css/compare/v2.0.4...v2.0.5) +================== + +* Fixed issue [#199](https://github.com/GoalSmashers/clean-css/issues/199) - keep line breaks with no advanced optimizations. + [2.0.4 / 2013-12-19](https://github.com/GoalSmashers/clean-css/compare/v2.0.3...v2.0.4) ================== diff --git a/lib/clean.js b/lib/clean.js index 12131dd5..069f02a9 100644 --- a/lib/clean.js +++ b/lib/clean.js @@ -286,7 +286,10 @@ CleanCSS.prototype.minify = function(data) { // remove space after (rgba|hsla) declaration - see #165 replace(/(rgba|hsla)\(([^\)]+)\) /g, '$1($2)'); - if (!options.noAdvanced) { + if (options.noAdvanced) { + if (options.keepBreaks) + replace(/\}/g, '}' + lineBreak); + } else { replace(function optimizeSelectors() { data = new SelectorsOptimizer(data, context, { keepBreaks: options.keepBreaks, diff --git a/test/unit-test.js b/test/unit-test.js index 98b57d2d..a31ae7b4 100644 --- a/test/unit-test.js +++ b/test/unit-test.js @@ -1154,6 +1154,12 @@ title']{display:block}", 'duplicate selectors with disabled advanced processing': cssContext({ 'of a duplicate selector': 'a,a{color:red}' }, { noAdvanced: true }), + 'line breaks with disabled advanced processing': cssContext({ + 'should be applied': [ + 'a{color:red}p{display:block}', + 'a{color:red}' + lineBreak + 'p{display:block}', + ] + }, { noAdvanced: true, keepBreaks: true }), 'invalid data tokenization': cssContext({ 'extra top-level closing brace': [ 'a{color:red}}p{width:auto}',