From 17b62b397972f6dc2dd3270e236c41c47a705d32 Mon Sep 17 00:00:00 2001 From: GoalSmashers Date: Wed, 11 Dec 2013 18:48:45 +0100 Subject: [PATCH] Deprecates '--selectors-merge-mode' in favor of a more generic '--compatibility' switch. * 'selectorsMergeMode' option to library is also renamed to 'compatibility'. --- History.md | 1 + README.md | 3 ++- bin/cleancss | 11 ++++++++--- lib/clean.js | 7 ++++++- test/unit-test.js | 2 +- 5 files changed, 18 insertions(+), 6 deletions(-) diff --git a/History.md b/History.md index 415c0695..2933e80a 100644 --- a/History.md +++ b/History.md @@ -1,6 +1,7 @@ [2.1.0 / 2013-xx-xx (UNRELEASED)](https://github.com/GoalSmashers/clean-css/compare/v2.0.0...HEAD) ================== +* Deprecates --selectors-merge-mode / selectorsMergeMode in favor to --compatibility / compatibility. * Skips empty removal if advanced processing is enabled. * Fixed issue [#160](https://github.com/GoalSmashers/clean-css/issues/160) - re-runs optimizer until a clean pass. * Fixed issue [#161](https://github.com/GoalSmashers/clean-css/issues/161) - improves tokenizer performance. diff --git a/README.md b/README.md index c5d8bb91..b0221430 100644 --- a/README.md +++ b/README.md @@ -71,7 +71,8 @@ cleancss [options] --skip-rebase Disable URLs rebasing --skip-advanced Disable advanced optimizations - selector & property merging, reduction, etc. ---selectors-merge-mode [ie8|*] Use `ie8` for compatibility mode, `*` for merge all (default) +--selectors-merge-mode [ie8|*] DEPRECATED: Use --compatibility switch +-c, --compatibility [ie8] Force compatibility mode -d, --debug Shows debug information (minification time & compression efficiency) ``` diff --git a/bin/cleancss b/bin/cleancss index 0db1805e..6fe291c3 100755 --- a/bin/cleancss +++ b/bin/cleancss @@ -26,7 +26,8 @@ commands .option('-s, --skip-import', 'Disable @import processing') .option('--skip-rebase', 'Disable URLs rebasing') .option('--skip-advanced', 'Disable advanced optimizations - selector & property merging, reduction, etc.') - .option('--selectors-merge-mode [ie8|*]', 'Use `ie8` for compatibility mode, `*` for merge all (default).') + .option('--selectors-merge-mode [ie8|*]', 'DEPRECATED: Use --compatibility switch') + .option('-c, --compatibility [ie8]', 'Force compatibility mode') .option('-d, --debug', 'Shows debug information (minification time & compression efficiency)'); commands.on('--help', function() { @@ -75,8 +76,12 @@ if (commands.skipRebase) cleanOptions.noRebase = true; if (commands.skipAdvanced) cleanOptions.noAdvanced = true; -if (commands.selectorsMergeMode) - cleanOptions.selectorsMergeMode = commands.selectorsMergeMode; +if (commands.compatibility) + cleanOptions.compatibility = commands.compatibility; +if (commands.selectorsMergeMode) { + console.warn('--selectors-merge-mode is deprecated and will be removed in clean-css 2.2. Please use --compatibility %s switch instead.', commands.selectorsMergeMode); + cleanOptions.compatibility = commands.selectorsMergeMode; +} if (commands.debug) cleanOptions.debug = true; if (commands.args.length > 0) { diff --git a/lib/clean.js b/lib/clean.js index 385f6e04..6ea60f1f 100644 --- a/lib/clean.js +++ b/lib/clean.js @@ -35,6 +35,11 @@ var CleanCSS = module.exports = function CleanCSS(options) { if (undefined === options.processImport) options.processImport = true; + if (options.selectorsMergeMode) { + console.warn('selectorsMergeMode is deprecated and will be removed in clean-css 2.2. Please use compatibility: \'%s\' option instead.', options.selectorsMergeMode); + options.compatibility = options.selectorsMergeMode; + } + this.options = options; this.stats = {}; this.context = { @@ -282,7 +287,7 @@ CleanCSS.prototype.minify = function(data) { data = new SelectorsOptimizer(data, context, { keepBreaks: options.keepBreaks, lineBreak: lineBreak, - selectorsMergeMode: options.selectorsMergeMode + selectorsMergeMode: options.compatibility == 'ie8' ? 'ie8' : '*' }).process(); }); } diff --git a/test/unit-test.js b/test/unit-test.js index 68253763..59f7e44c 100644 --- a/test/unit-test.js +++ b/test/unit-test.js @@ -1321,7 +1321,7 @@ title']{display:block}", ], 'of supported and unsupported selector': '.one:first-child{color:red}.two:last-child{color:red}', 'of two unsupported selectors': '.one:nth-child(5){color:red}.two:last-child{color:red}' - }, { selectorsMergeMode: 'ie8' }), + }, { compatibility: 'ie8' }), 'redefined more granular properties': redefineContext({ 'animation-delay': ['animation'], 'animation-direction': ['animation'], -- 2.34.1