Renames `noAdvanced` option into `advanced`.
authorJakub Pawlowicz <contact@jakubpawlowicz.com>
Fri, 10 Oct 2014 06:29:07 +0000 (07:29 +0100)
committerJakub Pawlowicz <contact@jakubpawlowicz.com>
Fri, 10 Oct 2014 20:27:45 +0000 (21:27 +0100)
History.md
README.md
bin/cleancss
lib/clean.js
lib/selectors/optimizer.js
test/integration-test.js
test/selectors/optimizer-test.js

index 18ab4c0..4cbb4b1 100644 (file)
@@ -5,6 +5,7 @@
 * Breaks 2.x compatibility for using CleanCSS as a function.
 * Reworks minification to tokenize first then minify.
   See [changes](https://github.com/jakubpawlowicz/clean-css/compare/b06f37d...dd8c14a).
+* Renames `noAdvanced` option into `advanced`.
 * Speeds up advanced processing by shortening optimize loop.
 * Fixed issue [#360](https://github.com/GoalSmashers/clean-css/issues/360) - adds 7 extra CSS colors.
 
index d30bfef..ac506be 100644 (file)
--- a/README.md
+++ b/README.md
@@ -24,6 +24,14 @@ Node.js 0.8.0+ (tested on CentOS, Ubuntu, OS X 10.6+, and Windows 7+)
 npm install clean-css
 ```
 
+### How to upgrade clean-css from 2.x to 3.x?
+
+#### Command-line interface (CLI) - no breaking changes.
+
+#### Module interface
+
+* `noAdvanced` became `advanced` - make sure to reverse the value;
+
 ### How to upgrade clean-css from 1.x to 2.x?
 
 #### Command-line interface (CLI)
@@ -121,13 +129,13 @@ var minimized = new CleanCSS().minify(source);
 CleanCSS constructor accepts a hash as a parameter, i.e.,
 `new CleanCSS(options).minify(source)` with the following options available:
 
+* `advanced` - set to false to disable advanced optimizations - selector & property merging, reduction, etc.
 * `benchmark` - turns on benchmarking mode measuring time spent on cleaning up (run `npm run bench` to see example)
 * `compatibility` - Force compatibility mode to `ie7` or `ie8`. Defaults to not set.
 * `debug` - set to true to get minification statistics under `stats` property (see `test/custom-test.js` for examples)
 * `inliner` - a hash of options for `@import` inliner, see test/protocol-imports-test.js for examples
 * `keepBreaks` - whether to keep line breaks (default is false)
 * `keepSpecialComments` - `*` for keeping all (default), `1` for keeping first one only, `0` for removing all
-* `noAdvanced` - set to true to disable advanced optimizations - selector & property merging, reduction, etc.
 * `noAggressiveMerging` - set to true to disable aggressive merging of properties.
 * `noRebase` - whether to skip URLs rebasing
 * `processImport` - whether to process `@import` rules
index 35e9837..ace2f25 100755 (executable)
@@ -75,7 +75,7 @@ if (commands.skipImport)
 if (commands.skipRebase)
   cleanOptions.noRebase = true;
 if (commands.skipAdvanced)
-  cleanOptions.noAdvanced = true;
+  cleanOptions.advanced = false;
 if (commands.skipAggressiveMerging)
   cleanOptions.noAggressiveMerging = true;
 if (commands.compatibility)
index ff72fc2..c6712aa 100644 (file)
@@ -18,13 +18,13 @@ var CleanCSS = module.exports = function CleanCSS(options) {
   options = options || {};
 
   this.options = {
+    advanced: options.advanced === undefined ? true : false,
     benchmark: options.benchmark,
     compatibility: options.compatibility,
     debug: options.debug,
     inliner: options.inliner,
     keepBreaks: options.keepBreaks || false,
     keepSpecialComments: 'keepSpecialComments' in options ? options.keepSpecialComments : '*',
-    noAdvanced: options.noAdvanced,
     noAggressiveMerging: options.noAggressiveMerging,
     noRebase: options.noRebase,
     processImport: undefined === options.processImport ? true : false,
@@ -118,7 +118,7 @@ function minify(data) {
   var urlRebase = new UrlRebase(options, context);
   var selectorsOptimizer = new SelectorsOptimizer({
     keepBreaks: options.keepBreaks,
-    noAdvanced: options.noAdvanced,
+    advanced: options.advanced,
     compatibility: options.compatibility,
     aggressiveMerging: !options.noAggressiveMerging,
     roundingPrecision: options.roundingPrecision
index 2ec661f..e33c87b 100644 (file)
@@ -41,7 +41,7 @@ SelectorsOptimizer.prototype.process = function (data) {
   var tokens = new Tokenizer(this.context).toTokens(data);
 
   new SimpleOptimizer(this.options).optimize(tokens);
-  if (!this.options.noAdvanced)
+  if (this.options.advanced)
     new AdvancedOptimizer(this.options, this.context).optimize(tokens);
 
   return rebuild(tokens, this.options.keepBreaks, false).trim();
index 73c143a..1eef650 100644 (file)
@@ -8,6 +8,7 @@ var CleanCSS = require('../index');
 var lineBreak = process.platform == 'win32' ? '\r\n' : '\n';
 var cssContext = function(groups, options) {
   var context = {};
+
   var clean = function(expectedCss) {
     return function(css) {
       var minifiedCss = new CleanCSS(options).minify(css);
@@ -1460,19 +1461,19 @@ title']{display:block}",
       '@import url(//fonts.googleapis.com/css?family=Domine:700);body h1{font-family:Domine}'
     ],
     'no empty body': '@import url(//fonts.googleapis.com/css?family=Domine:700);body{color:red}body h1{font-family:Domine}'
-  }, { processImport: false, noAdvanced: true }),
+  }, { processImport: false, advanced: false }),
   'duplicate selectors with disabled advanced processing': cssContext({
     'of a duplicate selector': [
       'a,a{color:red}',
       'a{color:red}'
     ]
-  }, { noAdvanced: true }),
+  }, { advanced: false }),
   '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 }),
+  }, { advanced: false, keepBreaks: true }),
   'invalid data tokenization': cssContext({
     'extra top-level closing brace': [
       'a{color:red}}p{width:auto}',
index b37c042..5ec0ddd 100644 (file)
@@ -148,7 +148,7 @@ vows.describe(SelectorsOptimizer)
         'a{padding:10px;margin:0;color:red}.one{color:red}a,p{color:red;padding:0}',
         'a{margin:0}.one{color:red}a,p{color:red;padding:0}'
       ]
-    }, { noAdvanced: false, aggressiveMerging: true })
+    }, { advanced: true, aggressiveMerging: true })
   )
   .addBatch(
     optimizerContext('advanced on & aggressive merging off', {
@@ -160,7 +160,7 @@ vows.describe(SelectorsOptimizer)
         'a{padding:10px;margin:0;color:red}.one{color:red}a,p{color:red;padding:0}',
         'a{padding:10px;margin:0}.one{color:red}a,p{color:red;padding:0}'
       ]
-    }, { noAdvanced: false, aggressiveMerging: false })
+    }, { advanced: true, aggressiveMerging: false })
   )
   .addBatch(
     optimizerContext('advanced off', {
@@ -184,7 +184,7 @@ vows.describe(SelectorsOptimizer)
         'a{color:red;display:block}.one{font-size:12px}a{color:#fff;margin:2px}',
         'a{color:red;display:block}.one{font-size:12px}a{color:#fff;margin:2px}'
       ]
-    }, { noAdvanced: true })
+    }, { advanced: false })
   )
   .addBatch(
     optimizerContext('@charset', {