From: Jakub Pawlowicz Date: Fri, 6 Jan 2017 12:56:24 +0000 (+0100) Subject: Fixes #836 - enables level `0` optimizations. X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=7dbc7c7f3027c406c69f020d62688425fb8c29ad;p=clean-css.git Fixes #836 - enables level `0` optimizations. Why: * Some people may need to bundle and rebase CSS without applying any optimizations. --- diff --git a/History.md b/History.md index 767a9db0..042fc68d 100644 --- a/History.md +++ b/History.md @@ -33,6 +33,7 @@ * Fixed issue [#828](https://github.com/jakubpawlowicz/clean-css/issues/828) - `-chrome-` hack support. * Fixed issue [#829](https://github.com/jakubpawlowicz/clean-css/issues/829) - adds more strict selector merging rules. * Fixed issue [#834](https://github.com/jakubpawlowicz/clean-css/issues/834) - adds extra line break in nested blocks. +* Fixed issue [#836](https://github.com/jakubpawlowicz/clean-css/issues/836) - enables level `0` optimizations. * Fixed issue [#839](https://github.com/jakubpawlowicz/clean-css/issues/839) - allows URIs in import inlining rules. * Fixed issue [#840](https://github.com/jakubpawlowicz/clean-css/issues/840) - allows input source map as map object. * Fixed issue [#843](https://github.com/jakubpawlowicz/clean-css/issues/843) - regression in selector handling. diff --git a/lib/clean.js b/lib/clean.js index 68b99e89..ec6c4914 100644 --- a/lib/clean.js +++ b/lib/clean.js @@ -121,7 +121,9 @@ function runner(localOnly) { function optimize(tokens, context) { var optimized; - optimized = basicOptimize(tokens, context); + optimized = OptimizationLevel.One in context.options.level ? + basicOptimize(tokens, context) : + tokens; optimized = OptimizationLevel.Two in context.options.level ? advancedOptimize(tokens, context, true) : optimized; diff --git a/test/optimizer/level-0/optimizations-test.js b/test/optimizer/level-0/optimizations-test.js new file mode 100644 index 00000000..7fa74a63 --- /dev/null +++ b/test/optimizer/level-0/optimizations-test.js @@ -0,0 +1,14 @@ +var vows = require('vows'); + +var optimizerContext = require('../../test-helper').optimizerContext; + +vows.describe('level 0') + .addBatch( + optimizerContext('optimizations', { + 'are off': [ + 'a{color:#f00;font-weight:bold}p{color:#f00}', + 'a{color:#f00;font-weight:bold}p{color:#f00}' + ] + }, { level: 0 }) + ) + .export(module);