From bf72328623537a9bb7ca77c6efe42165ac3bcbb7 Mon Sep 17 00:00:00 2001 From: Jakub Pawlowicz Date: Tue, 10 Jan 2017 14:39:51 +0100 Subject: [PATCH] Fixes #853 - renames level 2 options. Why: * To match level 1 wording which feels more natural. --- README.md | 52 +++--- bin/cleancss | 24 +-- lib/optimizer/level-2/compacting/optimize.js | 2 +- lib/optimizer/level-2/merge-media-queries.js | 4 +- .../level-2/merge-non-adjacent-by-body.js | 6 +- lib/optimizer/level-2/optimize.js | 20 +- lib/options/optimization-level.js | 20 +- test/batch-test.js | 6 +- test/binary-test.js | 8 +- test/integration-test.js | 2 +- test/module-test.js | 6 +- .../compacting/longhand-overriding-test.js | 8 +- .../level-2/compacting/optimize-test.js | 8 +- .../compacting/override-compacting-test.js | 2 +- .../compacting/shorthand-compacting-test.js | 2 +- test/optimizer/level-2/merge-adjacent-test.js | 4 +- .../level-2/merge-media-queries-test.js | 4 +- .../merge-non-adjacent-by-body-test.js | 10 +- .../merge-non-adjacent-by-selector-test.js | 8 +- .../level-2/reduce-non-adjacent-test.js | 8 +- .../remove-duplicate-font-at-rules-test.js | 4 +- .../remove-duplicate-media-queries-test.js | 6 +- .../level-2/remove-duplicates-test.js | 2 +- test/optimizer/level-2/restructure-test.js | 2 +- test/options/optimization-level-test.js | 172 +++++++++--------- test/source-map-test.js | 2 +- 26 files changed, 196 insertions(+), 196 deletions(-) diff --git a/README.md b/README.md index 4cfed0d9..9b339e6a 100644 --- a/README.md +++ b/README.md @@ -146,18 +146,18 @@ Level 2 optimizations: ```bash cleancss -O2 one.css -cleancss -O2 mediaMerging:off;restructuring:off;semanticMerging:on;shorthandCompacting:off one.css -cleancss -O2 all:off;duplicateRulesRemoving:on one.css -# `adjacentRulesMerging` controls adjacent rules merging; defaults to `on` -# `duplicateFontRulesRemoving` controls duplicate `@font-face` removing; defaults to `on` -# `duplicateMediaRemoving` controls duplicate `@media` removing; defaults to `on` -# `duplicateRulesRemoving` controls duplicate rules removing; defaults to `on` -# `mediaMerging` controls `@media` merging; defaults to `on` -# `nonAdjacentRulesMerging` controls non-adjacent rule merging; defaults to `on` -# `nonAdjacentRulesReducing` controls non-adjacent rule reducing; defaults to `on` -# `restructuring` controls content restructuring; defaults to `off` -# `semanticMerging` controls semantic merging; defaults to `off` -# `shorthandCompacting` controls shorthand compacting; defaults to `on` +cleancss -O2 mergeMedia:off;restructureRules:off;mergeSemantically:on;compactShorthands:off one.css +cleancss -O2 all:off;removeDuplicateRules:on one.css +# `compactShorthands` controls shorthand compacting; defaults to `on` +# `mergeAdjacentRules` controls adjacent rules merging; defaults to `on` +# `mergeMedia` controls `@media` merging; defaults to `on` +# `mergeNonAdjacentRules` controls non-adjacent rule merging; defaults to `on` +# `mergeSemantically` controls semantic merging; defaults to `off` +# `reduceNonAdjacentRules` controls non-adjacent rule reducing; defaults to `on` +# `removeDuplicateFontRules` controls duplicate `@font-face` removing; defaults to `on` +# `removeDuplicateMediaBlocks` controls duplicate `@media` removing; defaults to `on` +# `removeDuplicateRules` controls duplicate rules removing; defaults to `on` +# `restructureRules` controls rule restructuring; defaults to `off` ``` ### How to use clean-css API? @@ -234,7 +234,7 @@ new CleanCSS({ new CleanCSS({ level: { 1: { - all: false // sets all values to `false` + all: false, // sets all values to `false` tidySelectors: true // turns on optimizing selectors } } @@ -246,16 +246,16 @@ new CleanCSS({ new CleanCSS({ level: { 2: { - adjacentRulesMerging: true, // controls adjacent rules merging; defaults to true - duplicateFontRulesRemoving: true, // controls duplicate `@font-face` removing; defaults to true - duplicateMediaRemoving: true, // controls duplicate `@media` removing; defaults to true - duplicateRulesRemoving: true, // controls duplicate rules removing; defaults to true - mediaMerging: true, // controls `@media` merging; defaults to true - nonAdjacentRulesMerging: true, // controls non-adjacent rule merging; defaults to true - nonAdjacentRulesReducing: true, // controls non-adjacent rule reducing; defaults to true - restructuring: false, // controls content restructuring; defaults to false - semanticMerging: false, // controls semantic merging; defaults to false - shorthandCompacting: true, // controls shorthand compacting; defaults to true + compactShorthands: true, // controls shorthand compacting; defaults to true + mergeAdjacentRules: true, // controls adjacent rules merging; defaults to true + mergeMedia: true, // controls `@media` merging; defaults to true + mergeNonAdjacentRules: true, // controls non-adjacent rule merging; defaults to true + mergeSemantically: false, // controls semantic merging; defaults to false + reduceNonAdjacentRules: true, // controls non-adjacent rule reducing; defaults to true + removeDuplicateFontRules: true, // controls duplicate `@font-face` removing; defaults to true + removeDuplicateMediaBlocks: true, // controls duplicate `@media` removing; defaults to true + removeDuplicateRules: true, // controls duplicate rules removing; defaults to true + restructureRules: false // controls rule restructuring; defaults to false } } }); @@ -264,8 +264,8 @@ new CleanCSS({ new CleanCSS({ level: { 1: { - all: false // sets all values to `false` - duplicateRulesRemoving: true // turns on removing duplicate rules + all: false, // sets all values to `false` + removeDuplicateRules: true // turns on removing duplicate rules } } }); @@ -485,7 +485,7 @@ In library mode you can also pass `compatibility` as a hash of options. All level 2 optimizations are dispatched [here](https://github.com/jakubpawlowicz/clean-css/blob/master/lib/selectors/advanced.js#L59), and this is what they do: * `recursivelyOptimizeBlocks` - does all the following operations on a block (think `@media` or `@keyframe` at-rules); -* `recursivelyOptimizeProperties` - optimizes properties in rulesets and "flat at-rules" (like @font-face) by splitting them into components (e.g. `margin` into `margin-(*)`), optimizing, and rebuilding them back. You may want to use `shorthandCompacting` option to control whether you want to turn multiple (long-hand) properties into a shorthand ones; +* `recursivelyOptimizeProperties` - optimizes properties in rulesets and "flat at-rules" (like @font-face) by splitting them into components (e.g. `margin` into `margin-(*)`), optimizing, and rebuilding them back. You may want to use `compactShorthands` option to control whether you want to turn multiple (long-hand) properties into a shorthand ones; * `removeDuplicates` - gets rid of duplicate rulesets with exactly the same set of properties (think of including the same Sass / Less partial twice for no good reason); * `mergeAdjacent` - merges adjacent rulesets with the same selector or rules; * `reduceNonAdjacent` - identifies which properties are overridden in same-selector non-adjacent rulesets, and removes them; diff --git a/bin/cleancss b/bin/cleancss index f613afdf..06cd8c25 100755 --- a/bin/cleancss +++ b/bin/cleancss @@ -62,18 +62,18 @@ commands.on('--help', function () { console.log(''); console.log(' Level 2 optimizations:'); console.log(' %> cleancss -O2 one.css'); - console.log(' %> cleancss -O2 mediaMerging:off;restructuring:off;semanticMerging:on;shorthandCompacting:off one.css'); - console.log(' %> cleancss -O2 all:off;duplicateRulesRemoving:on one.css'); - console.log(' %> # `adjacentRulesMerging` controls adjacent rules merging; defaults to `on`'); - console.log(' %> # `duplicateFontRulesRemoving` controls duplicate `@font-face` removing; defaults to `on`'); - console.log(' %> # `duplicateMediaRemoving` controls duplicate `@media` removing; defaults to `on`'); - console.log(' %> # `duplicateRulesRemoving` controls duplicate rules removing; defaults to `on`'); - console.log(' %> # `mediaMerging` controls `@media` merging; defaults to `on`'); - console.log(' %> # `nonAdjacentRulesMerging` controls non-adjacent rule merging; defaults to `on`'); - console.log(' %> # `nonAdjacentRulesReducing` controls non-adjacent rule reducing; defaults to `on`'); - console.log(' %> # `restructuring` controls content restructuring; defaults to `off`'); - console.log(' %> # `semanticMerging` controls semantic merging; defaults to `off`'); - console.log(' %> # `shorthandCompacting` controls shorthand compacting; defaults to `on`'); + console.log(' %> cleancss -O2 mergeMedia:off;restructureRules:off;mergeSemantically:on;compactShorthands:off one.css'); + console.log(' %> cleancss -O2 all:off;removeDuplicateRules:on one.css'); + console.log(' %> # `compactShorthands` controls shorthand compacting; defaults to `on`'); + console.log(' %> # `mergeAdjacentRules` controls adjacent rules merging; defaults to `on`'); + console.log(' %> # `mergeMedia` controls `@media` merging; defaults to `on`'); + console.log(' %> # `mergeNonAdjacentRules` controls non-adjacent rule merging; defaults to `on`'); + console.log(' %> # `mergeSemantically` controls semantic merging; defaults to `off`'); + console.log(' %> # `reduceNonAdjacentRules` controls non-adjacent rule reducing; defaults to `on`'); + console.log(' %> # `removeDuplicateFontRules` controls duplicate `@font-face` removing; defaults to `on`'); + console.log(' %> # `removeDuplicateMediaBlocks` controls duplicate `@media` removing; defaults to `on`'); + console.log(' %> # `removeDuplicateRules` controls duplicate rules removing; defaults to `on`'); + console.log(' %> # `restructureRules` controls rule restructuring; defaults to `off`'); process.exit(); }); diff --git a/lib/optimizer/level-2/compacting/optimize.js b/lib/optimizer/level-2/compacting/optimize.js index 33a7118d..687e6177 100644 --- a/lib/optimizer/level-2/compacting/optimize.js +++ b/lib/optimizer/level-2/compacting/optimize.js @@ -210,7 +210,7 @@ function compactorOptimize(selector, properties, mergeAdjacent, withCompacting, } } - if (withCompacting && context.options.level[OptimizationLevel.Two].shorthandCompacting) { + if (withCompacting && context.options.level[OptimizationLevel.Two].compactShorthands) { compactOverrides(_properties, context.options.compatibility, validator); compactShorthands(_properties, validator); } diff --git a/lib/optimizer/level-2/merge-media-queries.js b/lib/optimizer/level-2/merge-media-queries.js index f5088762..0698c56b 100644 --- a/lib/optimizer/level-2/merge-media-queries.js +++ b/lib/optimizer/level-2/merge-media-queries.js @@ -8,7 +8,7 @@ var OptimizationLevel = require('../../options/optimization-level').Optimization var Token = require('../../tokenizer/token'); function mergeMediaQueries(tokens, context) { - var semanticMerging = context.options.level[OptimizationLevel.Two].semanticMerging; + var mergeSemantically = context.options.level[OptimizationLevel.Two].mergeSemantically; var candidates = {}; var reduced = []; @@ -52,7 +52,7 @@ function mergeMediaQueries(tokens, context) { var traversedProperties = extractProperties(tokens[from]); from += delta; - if (semanticMerging && allSameRulePropertiesCanBeReordered(movedProperties, traversedProperties)) { + if (mergeSemantically && allSameRulePropertiesCanBeReordered(movedProperties, traversedProperties)) { continue; } diff --git a/lib/optimizer/level-2/merge-non-adjacent-by-body.js b/lib/optimizer/level-2/merge-non-adjacent-by-body.js index ac7046a5..5046b046 100644 --- a/lib/optimizer/level-2/merge-non-adjacent-by-body.js +++ b/lib/optimizer/level-2/merge-non-adjacent-by-body.js @@ -36,7 +36,7 @@ function removeAnyUnsafeElements(left, candidates) { function mergeNonAdjacentByBody(tokens, context) { var options = context.options; - var semanticMerging = options.level[OptimizationLevel.Two].semanticMerging; + var mergeSemantically = options.level[OptimizationLevel.Two].mergeSemantically; var adjacentSpace = options.compatibility.selectors.adjacentSpace; var mergeablePseudoClasses = options.compatibility.selectors.mergeablePseudoClasses; var mergeablePseudoElements = options.compatibility.selectors.mergeablePseudoElements; @@ -47,10 +47,10 @@ function mergeNonAdjacentByBody(tokens, context) { if (token[0] != Token.RULE) continue; - if (token[2].length > 0 && (!semanticMerging && unsafeSelector(serializeRules(token[1])))) + if (token[2].length > 0 && (!mergeSemantically && unsafeSelector(serializeRules(token[1])))) candidates = {}; - if (token[2].length > 0 && semanticMerging && isBemElement(token)) + if (token[2].length > 0 && mergeSemantically && isBemElement(token)) removeAnyUnsafeElements(token, candidates); var candidateBody = serializeBody(token[2]); diff --git a/lib/optimizer/level-2/optimize.js b/lib/optimizer/level-2/optimize.js index 546a759a..3dae947e 100644 --- a/lib/optimizer/level-2/optimize.js +++ b/lib/optimizer/level-2/optimize.js @@ -72,44 +72,44 @@ function level2Optimize(tokens, context, withRestructuring) { recursivelyOptimizeBlocks(tokens, context); recursivelyOptimizeProperties(tokens, context); - if (levelOptions.duplicateRulesRemoving) { + if (levelOptions.removeDuplicateRules) { removeDuplicates(tokens, context); } - if (levelOptions.adjacentRulesMerging) { + if (levelOptions.mergeAdjacentRules) { mergeAdjacent(tokens, context); } - if (levelOptions.nonAdjacentRulesReducing) { + if (levelOptions.reduceNonAdjacentRules) { reduceNonAdjacent(tokens, context); } - if (levelOptions.nonAdjacentRulesMerging && levelOptions.nonAdjacentRulesMerging != 'body') { + if (levelOptions.mergeNonAdjacentRules && levelOptions.mergeNonAdjacentRules != 'body') { mergeNonAdjacentBySelector(tokens, context); } - if (levelOptions.nonAdjacentRulesMerging && levelOptions.nonAdjacentRulesMerging != 'selector') { + if (levelOptions.mergeNonAdjacentRules && levelOptions.mergeNonAdjacentRules != 'selector') { mergeNonAdjacentByBody(tokens, context); } - if (levelOptions.restructuring && levelOptions.adjacentRulesMerging && withRestructuring) { + if (levelOptions.restructureRules && levelOptions.mergeAdjacentRules && withRestructuring) { restructure(tokens, context); mergeAdjacent(tokens, context); } - if (levelOptions.restructuring && !levelOptions.adjacentRulesMerging && withRestructuring) { + if (levelOptions.restructureRules && !levelOptions.mergeAdjacentRules && withRestructuring) { restructure(tokens, context); } - if (levelOptions.duplicateFontRulesRemoving) { + if (levelOptions.removeDuplicateFontRules) { removeDuplicateFontAtRules(tokens, context); } - if (levelOptions.duplicateMediaRemoving) { + if (levelOptions.removeDuplicateMediaBlocks) { removeDuplicateMediaQueries(tokens, context); } - if (levelOptions.mediaMerging) { + if (levelOptions.mergeMedia) { reduced = mergeMediaQueries(tokens, context); for (i = reduced.length - 1; i >= 0; i--) { level2Optimize(reduced[i][2], context, false); diff --git a/lib/options/optimization-level.js b/lib/options/optimization-level.js index d54d090a..51d2d2e8 100644 --- a/lib/options/optimization-level.js +++ b/lib/options/optimization-level.js @@ -32,16 +32,16 @@ DEFAULTS[OptimizationLevel.One] = { tidySelectors: true }; DEFAULTS[OptimizationLevel.Two] = { - adjacentRulesMerging: true, - duplicateFontRulesRemoving: true, - duplicateMediaRemoving: true, - duplicateRulesRemoving: true, - mediaMerging: true, - nonAdjacentRulesMerging: true, - nonAdjacentRulesReducing: true, - restructuring: false, - semanticMerging: false, - shorthandCompacting: true + compactShorthands: true, + mergeAdjacentRules: true, + mergeMedia: true, + mergeNonAdjacentRules: true, + mergeSemantically: false, + reduceNonAdjacentRules: true, + removeDuplicateFontRules: true, + removeDuplicateMediaBlocks: true, + removeDuplicateRules: true, + restructureRules: false }; var ALL_KEYWORD_1 = '*'; diff --git a/test/batch-test.js b/test/batch-test.js index a2386a42..40b64981 100644 --- a/test/batch-test.js +++ b/test/batch-test.js @@ -50,7 +50,7 @@ function batchContexts() { keepBreaks: true, level: { 2: { - restructuring: true + restructureRules: true } } }).minify(data.input, this.callback.bind(null, data)); @@ -66,7 +66,7 @@ function batchContexts() { keepBreaks: true, level: { 2: { - restructuring: true + restructureRules: true } }, sourceMap: true @@ -79,7 +79,7 @@ function batchContexts() { 'minifying via CLI': { 'topic': function (data) { exec( - '__DIRECT__=1 ./bin/cleancss -b -O2 restructuring:on ' + (isIE7Mode ? '-c ie7 ' : '') + path.join(dir, filename), + '__DIRECT__=1 ./bin/cleancss -b -O2 restructureRules:on ' + (isIE7Mode ? '-c ie7 ' : '') + path.join(dir, filename), { maxBuffer: 500 * 1024 }, this.callback.bind(null, data) ); diff --git a/test/binary-test.js b/test/binary-test.js index e10189a8..32a1e143 100644 --- a/test/binary-test.js +++ b/test/binary-test.js @@ -169,7 +169,7 @@ vows.describe('./bin/cleancss') }) }) .addBatch({ - 'enable restructuring optimizations': pipedContext('div{margin-top:0}.one{margin:0}.two{display:block;margin-top:0}', '-O2 restructuring:on', { + 'enable restructuring optimizations': pipedContext('div{margin-top:0}.one{margin:0}.two{display:block;margin-top:0}', '-O2 restructureRules:on', { 'should do basic optimizations only': function (error, stdout) { assert.equal(stdout, '.two,div{margin-top:0}.one{margin:0}.two{display:block}'); } @@ -460,7 +460,7 @@ vows.describe('./bin/cleancss') } }) .addBatch({ - '@media merging': pipedContext('@media screen{a{color:red}}@media screen{a{display:block}}', '-O2 mediaMerging:off', { + '@media merging': pipedContext('@media screen{a{color:red}}@media screen{a{display:block}}', '-O2 mergeMedia:off', { 'gets right result': function (error, stdout) { assert.equal(stdout, '@media screen{a{color:red}}@media screen{a{display:block}}'); } @@ -468,7 +468,7 @@ vows.describe('./bin/cleancss') }) .addBatch({ 'shorthand compacting': { - 'of (yet) unmergeable properties': pipedContext('a{background:url(image.png);background-color:red}', '-O2 shorthandCompacting:off', { + 'of (yet) unmergeable properties': pipedContext('a{background:url(image.png);background-color:red}', '-O2 compactShorthands:off', { 'gets right result': function (error, stdout) { assert.equal(stdout, 'a{background:url(image.png);background-color:red}'); } @@ -622,7 +622,7 @@ vows.describe('./bin/cleancss') assert.equal(stdout, '.a{margin:0}.b{margin:10px;padding:0}.c{margin:0}'); } }), - 'enabled': pipedContext('.a{margin:0}.b{margin:10px;padding:0}.c{margin:0}', '-O2 semanticMerging:on', { + 'enabled': pipedContext('.a{margin:0}.b{margin:10px;padding:0}.c{margin:0}', '-O2 mergeSemantically:on', { 'should output right data': function (error, stdout) { assert.equal(stdout, '.a,.c{margin:0}.b{margin:10px;padding:0}'); } diff --git a/test/integration-test.js b/test/integration-test.js index de7ea438..137a308c 100644 --- a/test/integration-test.js +++ b/test/integration-test.js @@ -2221,7 +2221,7 @@ vows.describe('integration tests') '.one{color:red;margin:0}.two{color:red}.one{margin:0}', '.one,.two{color:red}.one{margin:0}' ] - }, { level: { 2: { restructuring: true } } }) + }, { level: { 2: { restructureRules: true } } }) ) .addBatch( optimizerContext('units - IE8 compatibility', { diff --git a/test/module-test.js b/test/module-test.js index f31e34f9..a3ede008 100644 --- a/test/module-test.js +++ b/test/module-test.js @@ -341,7 +341,7 @@ vows.describe('module tests').addBatch({ }, 'restructuring - on': { 'topic': function () { - new CleanCSS({ level: { 2: { restructuring: true } } }).minify('div{margin-top:0}.one{margin:0}.two{display:block;margin-top:0}', this.callback); + new CleanCSS({ level: { 2: { restructureRules: true } } }).minify('div{margin-top:0}.one{margin:0}.two{display:block;margin-top:0}', this.callback); }, 'gets right output': function (minified) { assert.equal(minified.styles, '.two,div{margin-top:0}.one{margin:0}.two{display:block}'); @@ -349,7 +349,7 @@ vows.describe('module tests').addBatch({ }, 'restructuring - off': { 'topic': function () { - return new CleanCSS({ level: { 2: { restructuring: false } } }).minify('div{margin-top:0}.one{margin:0}.two{display:block;margin-top:0}'); + return new CleanCSS({ level: { 2: { restructureRules: false } } }).minify('div{margin-top:0}.one{margin:0}.two{display:block;margin-top:0}'); }, 'gets right output': function (minified) { assert.equal(minified.styles, 'div{margin-top:0}.one{margin:0}.two{display:block;margin-top:0}'); @@ -365,7 +365,7 @@ vows.describe('module tests').addBatch({ }, 'semantic merging - on': { 'topic': function () { - return new CleanCSS({ level: { 2: { semanticMerging: true } } }).minify('.a{margin:0}.b{margin:10px;padding:0}.c{margin:0}'); + return new CleanCSS({ level: { 2: { mergeSemantically: true } } }).minify('.a{margin:0}.b{margin:10px;padding:0}.c{margin:0}'); }, 'gets right output': function (minified) { assert.equal(minified.styles, '.a,.c{margin:0}.b{margin:10px;padding:0}'); diff --git a/test/optimizer/level-2/compacting/longhand-overriding-test.js b/test/optimizer/level-2/compacting/longhand-overriding-test.js index 51431a70..dc093847 100644 --- a/test/optimizer/level-2/compacting/longhand-overriding-test.js +++ b/test/optimizer/level-2/compacting/longhand-overriding-test.js @@ -21,10 +21,10 @@ function _optimize(source) { compatibility: compat, level: { 2: { - mediaMerging: true, - restructuring: true, - semanticMerging: false, - shorthandCompacting: true + mergeMedia: true, + restructureRules: true, + mergeSemantically: false, + compactShorthands: true } } }; diff --git a/test/optimizer/level-2/compacting/optimize-test.js b/test/optimizer/level-2/compacting/optimize-test.js index cc3d42c8..62d07358 100644 --- a/test/optimizer/level-2/compacting/optimize-test.js +++ b/test/optimizer/level-2/compacting/optimize-test.js @@ -15,10 +15,10 @@ function _optimize(source, mergeAdjacent, aggressiveMerging, compatibilityOption compatibility: compat, level: { 2: { - mediaMerging: false, - restructuring: false, - semanticMerging: false, - shorthandCompacting: false + mergeMedia: false, + restructureRules: false, + mergeSemantically: false, + compactShorthands: false } } }; diff --git a/test/optimizer/level-2/compacting/override-compacting-test.js b/test/optimizer/level-2/compacting/override-compacting-test.js index 5199bbba..e93bed44 100644 --- a/test/optimizer/level-2/compacting/override-compacting-test.js +++ b/test/optimizer/level-2/compacting/override-compacting-test.js @@ -22,7 +22,7 @@ function _optimize(source, compat, aggressiveMerging) { compatibility: compat, level: { 2: { - shorthandCompacting: true + compactShorthands: true } } }; diff --git a/test/optimizer/level-2/compacting/shorthand-compacting-test.js b/test/optimizer/level-2/compacting/shorthand-compacting-test.js index ed20af09..f0cfad83 100644 --- a/test/optimizer/level-2/compacting/shorthand-compacting-test.js +++ b/test/optimizer/level-2/compacting/shorthand-compacting-test.js @@ -22,7 +22,7 @@ function _optimize(source) { compatibility: compat, level: { 2: { - shorthandCompacting: true + compactShorthands: true } } }; diff --git a/test/optimizer/level-2/merge-adjacent-test.js b/test/optimizer/level-2/merge-adjacent-test.js index 62dca5e0..fa3c2627 100644 --- a/test/optimizer/level-2/merge-adjacent-test.js +++ b/test/optimizer/level-2/merge-adjacent-test.js @@ -96,7 +96,7 @@ vows.describe('remove duplicates') '.one{color:red}@media print{.two{display:block}}.three{color:red}', '.one,.three{color:red}@media print{.two{display:block}}' ], - }, { level: { 2: { restructuring: true } } }) + }, { level: { 2: { restructureRules: true } } }) ) .addBatch( optimizerContext('with level 2 off but only adjacentRuleMerging on', { @@ -104,7 +104,7 @@ vows.describe('remove duplicates') 'a{background:url(image.png)}a{display:block;width:75px;background-repeat:no-repeat}', 'a{background:url(image.png);display:block;width:75px;background-repeat:no-repeat}', ], - }, { level: { 2: { all: false, adjacentRulesMerging: true } } }) + }, { level: { 2: { all: false, mergeAdjacentRules: true } } }) ) .addBatch( optimizerContext('with level 2 off', { diff --git a/test/optimizer/level-2/merge-media-queries-test.js b/test/optimizer/level-2/merge-media-queries-test.js index fdd1420a..8aa1f9e3 100644 --- a/test/optimizer/level-2/merge-media-queries-test.js +++ b/test/optimizer/level-2/merge-media-queries-test.js @@ -116,7 +116,7 @@ vows.describe('merge media queries') '@media (max-width:1px){.block{margin:1px}}.block__element{margin:2px}@media (max-width:1px){.block--modifier{margin:3px}}', '.block__element{margin:2px}@media (max-width:1px){.block{margin:1px}.block--modifier{margin:3px}}' ] - }, { level: { 2: { semanticMerging: true } } }) + }, { level: { 2: { mergeSemantically: true } } }) ) .addBatch( optimizerContext('with level 2 off', { @@ -132,6 +132,6 @@ vows.describe('merge media queries') '@media screen{a{color:red}}@media screen{a{display:block}}', '@media screen{a{color:red}}@media screen{a{display:block}}' ] - }, { level: { 2: { mediaMerging: false } } }) + }, { level: { 2: { mergeMedia: false } } }) ) .export(module); diff --git a/test/optimizer/level-2/merge-non-adjacent-by-body-test.js b/test/optimizer/level-2/merge-non-adjacent-by-body-test.js index e995977f..0e7831c6 100644 --- a/test/optimizer/level-2/merge-non-adjacent-by-body-test.js +++ b/test/optimizer/level-2/merge-non-adjacent-by-body-test.js @@ -35,20 +35,20 @@ vows.describe('merge non djacent by body') }, { level: 2 }) ) .addBatch( - optimizerContext('with level 2 off but nonAdjacentRulesMerging on', { + optimizerContext('with level 2 off but mergeNonAdjacentRules on', { 'of element selectors': [ 'p{color:red}div{display:block}span{color:red}', 'p,span{color:red}div{display:block}' ] - }, { level: { 2: { all: false, nonAdjacentRulesMerging: true } } }) + }, { level: { 2: { all: false, mergeNonAdjacentRules: true } } }) ) .addBatch( - optimizerContext('with level 2 off but nonAdjacentRulesMerging set to selector', { + optimizerContext('with level 2 off but mergeNonAdjacentRules set to selector', { 'of element selectors': [ 'p{color:red}div{display:block}span{color:red}', 'p{color:red}div{display:block}span{color:red}' ] - }, { level: { 2: { all: false, nonAdjacentRulesMerging: 'selector' } } }) + }, { level: { 2: { all: false, mergeNonAdjacentRules: 'selector' } } }) ) .addBatch( optimizerContext('with level 2 off', { @@ -101,7 +101,7 @@ vows.describe('merge non djacent by body') '.block1__element{color:#000}.block1__element--modifier{color:red}.block2{color:#000;display:block;width:100%}' // '.block1__element,.block2{color:#000}.block1__element--modifier{color:red}.block2{display:block;width:100%}' - pending #588 ] - }, { level: { 2: { restructuring: true, semanticMerging: true } } }) + }, { level: { 2: { restructureRules: true, mergeSemantically: true } } }) ) .addBatch( optimizerContext('IE8 compatibility', { diff --git a/test/optimizer/level-2/merge-non-adjacent-by-selector-test.js b/test/optimizer/level-2/merge-non-adjacent-by-selector-test.js index 6f1414f0..80657702 100644 --- a/test/optimizer/level-2/merge-non-adjacent-by-selector-test.js +++ b/test/optimizer/level-2/merge-non-adjacent-by-selector-test.js @@ -19,20 +19,20 @@ vows.describe('merge non djacent by selector') }, { level: 2 }) ) .addBatch( - optimizerContext('with level 2 off but nonAdjacentRulesMerging on', { + optimizerContext('with level 2 off but mergeNonAdjacentRules on', { 'of element selectors': [ '.one{color:red}.two{color:#fff}.one{font-weight:400}', '.one{color:red;font-weight:400}.two{color:#fff}' ] - }, { level: { 2: { all: false, nonAdjacentRulesMerging: true } } }) + }, { level: { 2: { all: false, mergeNonAdjacentRules: true } } }) ) .addBatch( - optimizerContext('with level 2 off but nonAdjacentRulesMerging set to body', { + optimizerContext('with level 2 off but mergeNonAdjacentRules set to body', { 'of element selectors': [ '.one{color:red}.two{color:#fff}.one{font-weight:400}', '.one{color:red}.two{color:#fff}.one{font-weight:400}' ] - }, { level: { 2: { all: false, nonAdjacentRulesMerging: 'body' } } }) + }, { level: { 2: { all: false, mergeNonAdjacentRules: 'body' } } }) ) .addBatch( optimizerContext('level 2 off', { diff --git a/test/optimizer/level-2/reduce-non-adjacent-test.js b/test/optimizer/level-2/reduce-non-adjacent-test.js index 97097352..03463a1d 100644 --- a/test/optimizer/level-2/reduce-non-adjacent-test.js +++ b/test/optimizer/level-2/reduce-non-adjacent-test.js @@ -116,7 +116,7 @@ vows.describe('remove duplicates') 'a{padding:10px;margin:0;color:red}.one{color:red}a,p{color:red;padding:0}.one,a{color:#fff}', 'a{margin:0}a,p{color:red;padding:0}.one,a{color:#fff}' ] - }, { level: { 2: { restructuring: true } } }) + }, { level: { 2: { restructureRules: true } } }) ) .addBatch( optimizerContext('level 2 on and aggressive merging off', { @@ -124,15 +124,15 @@ vows.describe('remove duplicates') 'a{padding:10px;margin:0;color:red}.one{color:red}a,p{color:red;padding:0}', '.one,a,p{color:red}a{padding:10px;margin:0}a,p{padding:0}' ] - }, { aggressiveMerging: false, level: { 2: { restructuring: true } } }) + }, { aggressiveMerging: false, level: { 2: { restructureRules: true } } }) ) .addBatch( - optimizerContext('level 2 off but nonAdjacentRulesReducing on', { + optimizerContext('level 2 off but reduceNonAdjacentRules on', { 'non-adjacent with multi selectors': [ 'a{padding:10px;margin:0;color:red}.one{color:red}a,p{color:red;padding:0}', 'a{margin:0;color:red}.one{color:red}a,p{color:red;padding:0}' ] - }, { level: { 2: { all: false, nonAdjacentRulesReducing: true } } }) + }, { level: { 2: { all: false, reduceNonAdjacentRules: true } } }) ) .addBatch( optimizerContext('level 2 off', { diff --git a/test/optimizer/level-2/remove-duplicate-font-at-rules-test.js b/test/optimizer/level-2/remove-duplicate-font-at-rules-test.js index 7ed12ebc..cba1ae07 100644 --- a/test/optimizer/level-2/remove-duplicate-font-at-rules-test.js +++ b/test/optimizer/level-2/remove-duplicate-font-at-rules-test.js @@ -19,12 +19,12 @@ vows.describe('remove duplicate @font-face at-rules') }, { level: 2 }) ) .addBatch( - optimizerContext('level 2 off but duplicateFontRulesRemoving on', { + optimizerContext('level 2 off but removeDuplicateFontRules on', { 'non-adjacent': [ '@font-face{font-family:test;src:url(fonts/test.woff2)}.one{color:red}@font-face{font-family:test;src:url(fonts/test.woff2)}', '@font-face{font-family:test;src:url(fonts/test.woff2)}.one{color:red}' ] - }, { level: { 2: { all: false, duplicateFontRulesRemoving: true } } }) + }, { level: { 2: { all: false, removeDuplicateFontRules: true } } }) ) .addBatch( optimizerContext('level 2 off', { diff --git a/test/optimizer/level-2/remove-duplicate-media-queries-test.js b/test/optimizer/level-2/remove-duplicate-media-queries-test.js index cfa9e510..6f7c40b2 100644 --- a/test/optimizer/level-2/remove-duplicate-media-queries-test.js +++ b/test/optimizer/level-2/remove-duplicate-media-queries-test.js @@ -23,12 +23,12 @@ vows.describe('remove duplicate media queries') }, { level: 2 }) ) .addBatch( - optimizerContext('level 2 off but duplicateMediaRemoving on', { + optimizerContext('level 2 off but removeDuplicateMediaBlocks on', { 'non-adjacent': [ '@media screen{a{color:red}}@media print{a{color:#fff}}@media screen{a{color:red}}', '@media print{a{color:#fff}}@media screen{a{color:red}}' ] - }, { level: { 2: { all: false, duplicateMediaRemoving: true } } }) + }, { level: { 2: { all: false, removeDuplicateMediaBlocks: true } } }) ) .addBatch( optimizerContext('level 2 off', { @@ -44,6 +44,6 @@ vows.describe('remove duplicate media queries') '@media screen{a{color:red}}@media screen{div{color:red}}', '@media screen{a{color:red}}@media screen{div{color:red}}' ] - }, { level: { 2: { mediaMerging: false } } }) + }, { level: { 2: { mergeMedia: false } } }) ) .export(module); diff --git a/test/optimizer/level-2/remove-duplicates-test.js b/test/optimizer/level-2/remove-duplicates-test.js index 4c84bdaa..e2a387a7 100644 --- a/test/optimizer/level-2/remove-duplicates-test.js +++ b/test/optimizer/level-2/remove-duplicates-test.js @@ -48,7 +48,7 @@ vows.describe('remove duplicates') 'a{color:red}div{color:blue}a{color:red}', 'div{color:#00f}a{color:red}' ] - }, { level: { 2: { all: false, duplicateRulesRemoving: true } } }) + }, { level: { 2: { all: false, removeDuplicateRules: true } } }) ) .addBatch( optimizerContext('level 2 off', { diff --git a/test/optimizer/level-2/restructure-test.js b/test/optimizer/level-2/restructure-test.js index 0d20b33e..567f892d 100644 --- a/test/optimizer/level-2/restructure-test.js +++ b/test/optimizer/level-2/restructure-test.js @@ -164,7 +164,7 @@ vows.describe('restructure') '.one{border-color:#000;border-bottom-color:rgb(0,0,0,.2)}.two{border-color:#fff;border-bottom-color:rgb(0,0,0,.2)}', '.one{border-color:#000;border-bottom-color:rgb(0,0,0,.2)}.two{border-color:#fff;border-bottom-color:rgb(0,0,0,.2)}' ] - }, { level: { 2: { restructuring: true } } }) + }, { level: { 2: { restructureRules: true } } }) ) .addBatch( optimizerContext('level 2 off', { diff --git a/test/options/optimization-level-test.js b/test/options/optimization-level-test.js index 932e7ba1..2cb1c58d 100644 --- a/test/options/optimization-level-test.js +++ b/test/options/optimization-level-test.js @@ -121,16 +121,16 @@ vows.describe(optimizationLevelFrom) }, 'has level 2 options': function (levelOptions) { assert.deepEqual(levelOptions['2'], { - adjacentRulesMerging: true, - duplicateFontRulesRemoving: true, - duplicateMediaRemoving: true, - duplicateRulesRemoving: true, - mediaMerging: true, - nonAdjacentRulesMerging: true, - nonAdjacentRulesReducing: true, - restructuring: false, - semanticMerging: false, - shorthandCompacting: true + compactShorthands: true, + mergeAdjacentRules: true, + mergeMedia: true, + mergeNonAdjacentRules: true, + mergeSemantically: false, + reduceNonAdjacentRules: true, + removeDuplicateFontRules: true, + removeDuplicateMediaBlocks: true, + removeDuplicateRules: true, + restructureRules: false }); } }, @@ -180,16 +180,16 @@ vows.describe(optimizationLevelFrom) }, 'has level 2 options': function (levelOptions) { assert.deepEqual(levelOptions['2'], { - adjacentRulesMerging: true, - duplicateFontRulesRemoving: true, - duplicateMediaRemoving: true, - duplicateRulesRemoving: true, - mediaMerging: true, - nonAdjacentRulesMerging: true, - nonAdjacentRulesReducing: true, - restructuring: false, - semanticMerging: false, - shorthandCompacting: true + compactShorthands: true, + mergeAdjacentRules: true, + mergeMedia: true, + mergeNonAdjacentRules: true, + mergeSemantically: false, + reduceNonAdjacentRules: true, + removeDuplicateFontRules: true, + removeDuplicateMediaBlocks: true, + removeDuplicateRules: true, + restructureRules: false }); } }, @@ -263,7 +263,7 @@ vows.describe(optimizationLevelFrom) }, 'a hash with all keyword for level 2': { 'topic': function () { - return optimizationLevelFrom({ 1: { specialComments: 0 }, 2: { all: false, mediaMerging: true } }); + return optimizationLevelFrom({ 1: { specialComments: 0 }, 2: { all: false, mergeMedia: true } }); }, 'has all options': function (levelOptions) { assert.deepEqual(Object.keys(levelOptions), ['0', '1', '2']); @@ -296,22 +296,22 @@ vows.describe(optimizationLevelFrom) }, 'has level 2 options': function (levelOptions) { assert.deepEqual(levelOptions['2'], { - adjacentRulesMerging: false, - duplicateFontRulesRemoving: false, - duplicateMediaRemoving: false, - duplicateRulesRemoving: false, - mediaMerging: true, - nonAdjacentRulesMerging: false, - nonAdjacentRulesReducing: false, - restructuring: false, - semanticMerging: false, - shorthandCompacting: false + compactShorthands: false, + mergeAdjacentRules: false, + mergeMedia: true, + mergeNonAdjacentRules: false, + mergeSemantically: false, + reduceNonAdjacentRules: false, + removeDuplicateFontRules: false, + removeDuplicateMediaBlocks: false, + removeDuplicateRules: false, + restructureRules: false }); } }, 'a hash with * keyword for level 2': { 'topic': function () { - return optimizationLevelFrom({ 1: { specialComments: 0 }, 2: { '*': false, mediaMerging: true } }); + return optimizationLevelFrom({ 1: { specialComments: 0 }, 2: { '*': false, mergeMedia: true } }); }, 'has all options': function (levelOptions) { assert.deepEqual(Object.keys(levelOptions), ['0', '1', '2']); @@ -344,16 +344,16 @@ vows.describe(optimizationLevelFrom) }, 'has level 2 options': function (levelOptions) { assert.deepEqual(levelOptions['2'], { - adjacentRulesMerging: false, - duplicateFontRulesRemoving: false, - duplicateMediaRemoving: false, - duplicateRulesRemoving: false, - mediaMerging: true, - nonAdjacentRulesMerging: false, - nonAdjacentRulesReducing: false, - restructuring: false, - semanticMerging: false, - shorthandCompacting: false + compactShorthands: false, + mergeAdjacentRules: false, + mergeMedia: true, + mergeNonAdjacentRules: false, + mergeSemantically: false, + reduceNonAdjacentRules: false, + removeDuplicateFontRules: false, + removeDuplicateMediaBlocks: false, + removeDuplicateRules: false, + restructureRules: false }); } }, @@ -393,7 +393,7 @@ vows.describe(optimizationLevelFrom) }, 'a hash with options as strings with boolean values': { 'topic': function () { - return optimizationLevelFrom({ 2: 'mediaMerging:false;semanticMerging:true' }); + return optimizationLevelFrom({ 2: 'mergeMedia:false;mergeSemantically:true' }); }, 'has all options': function (levelOptions) { assert.deepEqual(Object.keys(levelOptions), ['0', '1', '2']); @@ -426,22 +426,22 @@ vows.describe(optimizationLevelFrom) }, 'has level 2 options': function (levelOptions) { assert.deepEqual(levelOptions['2'], { - adjacentRulesMerging: true, - duplicateFontRulesRemoving: true, - duplicateMediaRemoving: true, - duplicateRulesRemoving: true, - mediaMerging: false, - nonAdjacentRulesMerging: true, - nonAdjacentRulesReducing: true, - restructuring: false, - semanticMerging: true, - shorthandCompacting: true + compactShorthands: true, + mergeAdjacentRules: true, + mergeMedia: false, + mergeNonAdjacentRules: true, + mergeSemantically: true, + reduceNonAdjacentRules: true, + removeDuplicateFontRules: true, + removeDuplicateMediaBlocks: true, + removeDuplicateRules: true, + restructureRules: false }); } }, 'a hash with options as strings with boolean values as on/off': { 'topic': function () { - return optimizationLevelFrom({ 2: 'mediaMerging:off;semanticMerging:on' }); + return optimizationLevelFrom({ 2: 'mergeMedia:off;mergeSemantically:on' }); }, 'has all options': function (levelOptions) { assert.deepEqual(Object.keys(levelOptions), ['0', '1', '2']); @@ -474,22 +474,22 @@ vows.describe(optimizationLevelFrom) }, 'has level 2 options': function (levelOptions) { assert.deepEqual(levelOptions['2'], { - adjacentRulesMerging: true, - duplicateFontRulesRemoving: true, - duplicateMediaRemoving: true, - duplicateRulesRemoving: true, - mediaMerging: false, - nonAdjacentRulesMerging: true, - nonAdjacentRulesReducing: true, - restructuring: false, - semanticMerging: true, - shorthandCompacting: true + compactShorthands: true, + mergeAdjacentRules: true, + mergeMedia: false, + mergeNonAdjacentRules: true, + mergeSemantically: true, + reduceNonAdjacentRules: true, + removeDuplicateFontRules: true, + removeDuplicateMediaBlocks: true, + removeDuplicateRules: true, + restructureRules: false }); } }, 'a hash with options as strings with all keyword': { 'topic': function () { - return optimizationLevelFrom({ 2: 'all:false;mediaMerging:true;semanticMerging:true' }); + return optimizationLevelFrom({ 2: 'all:false;mergeMedia:true;mergeSemantically:true' }); }, 'has all options': function (levelOptions) { assert.deepEqual(Object.keys(levelOptions), ['0', '1', '2']); @@ -522,22 +522,22 @@ vows.describe(optimizationLevelFrom) }, 'has level 2 options': function (levelOptions) { assert.deepEqual(levelOptions['2'], { - adjacentRulesMerging: false, - duplicateFontRulesRemoving: false, - duplicateMediaRemoving: false, - duplicateRulesRemoving: false, - mediaMerging: true, - nonAdjacentRulesMerging: false, - nonAdjacentRulesReducing: false, - restructuring: false, - semanticMerging: true, - shorthandCompacting: false + compactShorthands: false, + mergeAdjacentRules: false, + mergeMedia: true, + mergeNonAdjacentRules: false, + mergeSemantically: true, + reduceNonAdjacentRules: false, + removeDuplicateFontRules: false, + removeDuplicateMediaBlocks: false, + removeDuplicateRules: false, + restructureRules: false }); } }, 'a hash with options as strings with * keyword': { 'topic': function () { - return optimizationLevelFrom({ 2: '*:false;mediaMerging:true;semanticMerging:true' }); + return optimizationLevelFrom({ 2: '*:false;mergeMedia:true;mergeSemantically:true' }); }, 'has all options': function (levelOptions) { assert.deepEqual(Object.keys(levelOptions), ['0', '1', '2']); @@ -570,16 +570,16 @@ vows.describe(optimizationLevelFrom) }, 'has level 2 options': function (levelOptions) { assert.deepEqual(levelOptions['2'], { - adjacentRulesMerging: false, - duplicateFontRulesRemoving: false, - duplicateMediaRemoving: false, - duplicateRulesRemoving: false, - mediaMerging: true, - nonAdjacentRulesMerging: false, - nonAdjacentRulesReducing: false, - restructuring: false, - semanticMerging: true, - shorthandCompacting: false + compactShorthands: false, + mergeAdjacentRules: false, + mergeMedia: true, + mergeNonAdjacentRules: false, + mergeSemantically: true, + reduceNonAdjacentRules: false, + removeDuplicateFontRules: false, + removeDuplicateMediaBlocks: false, + removeDuplicateRules: false, + restructureRules: false }); } }, diff --git a/test/source-map-test.js b/test/source-map-test.js index 5ef05fe5..d22079b5 100644 --- a/test/source-map-test.js +++ b/test/source-map-test.js @@ -1816,7 +1816,7 @@ vows.describe('source-map') 'level 2 optimizations': { 'new property in restructuring': { 'topic': function () { - return new CleanCSS({ level: { 2: { restructuring: true } }, sourceMap: true }).minify('a{color:#000}div{color:red}.one{display:block}.two{display:inline;color:red}'); + return new CleanCSS({ level: { 2: { restructureRules: true } }, sourceMap: true }).minify('a{color:#000}div{color:red}.one{display:block}.two{display:inline;color:red}'); }, 'has right output': function (minified) { assert.equal(minified.styles, 'a{color:#000}.two,div{color:red}.one{display:block}.two{display:inline}'); -- 2.34.1