From e1b178a0781d81d75cf003c3b0a1df0ef25bafd2 Mon Sep 17 00:00:00 2001 From: Jakub Pawlowicz Date: Wed, 20 May 2015 21:03:55 +0100 Subject: [PATCH] Fixes #579 - disables `background-origin` merging into shorthand. It seems to be only compatible with IE10+ so we'll keep it disabled for now. --- History.md | 1 + README.md | 3 ++- lib/properties/override-compactor.js | 1 + lib/utils/compatibility.js | 3 +++ test/integration-test.js | 10 ---------- test/properties/override-compacting-test.js | 17 +++++++++++++++++ test/utils/compatibility-test.js | 7 +++++++ 7 files changed, 31 insertions(+), 11 deletions(-) diff --git a/History.md b/History.md index 413b0de1..e174d7dd 100644 --- a/History.md +++ b/History.md @@ -17,6 +17,7 @@ * Fixed issue [#574](https://github.com/jakubpawlowicz/clean-css/issues/574) - rewriting internal URLs. * Fixed issue [#575](https://github.com/jakubpawlowicz/clean-css/issues/575) - missing directory as a `target`. * Fixed issue [#577](https://github.com/jakubpawlowicz/clean-css/issues/577) - `background-clip` into shorthand. +* Fixed issue [#579](https://github.com/jakubpawlowicz/clean-css/issues/579) - `background-origin` into shorthand. [3.2.10 / 2015-05-14](https://github.com/jakubpawlowicz/clean-css/compare/v3.2.9...v3.2.10) ================== diff --git a/README.md b/README.md index 721a59f6..1c454813 100644 --- a/README.md +++ b/README.md @@ -305,8 +305,9 @@ Since clean-css 3 a fine grained control is available over with the following options available: * `'[+-]colors.opacity'` - - turn on (+) / off (-) `rgba()` / `hsla()` declarations removal -* `'[+-]properties.backgroundSizeMerging'` - turn on / off background-size merging into shorthand * `'[+-]properties.backgroundClipMerging'` - turn on / off background-clip merging into shorthand +* `'[+-]properties.backgroundOriginMerging'` - turn on / off background-origin merging into shorthand +* `'[+-]properties.backgroundSizeMerging'` - turn on / off background-size merging into shorthand * `'[+-]properties.colors'` - turn on / off any color optimizations * `'[+-]properties.iePrefixHack'` - turn on / off IE prefix hack removal * `'[+-]properties.ieSuffixHack'` - turn on / off IE suffix hack removal diff --git a/lib/properties/override-compactor.js b/lib/properties/override-compactor.js index 8357969a..bd0de508 100644 --- a/lib/properties/override-compactor.js +++ b/lib/properties/override-compactor.js @@ -271,6 +271,7 @@ function compactOverrides(properties, compatibility, validator) { if (everyCombination(mayOverride, component, right, validator)) { var disabledBackgroundMerging = !compatibility.properties.backgroundClipMerging && component.name.indexOf('background-clip') > -1 || + !compatibility.properties.backgroundOriginMerging && component.name.indexOf('background-origin') > -1 || !compatibility.properties.backgroundSizeMerging && component.name.indexOf('background-size') > -1; var nonMergeableValue = compactable[right.name].nonMergeableValue === right.value[0][0]; diff --git a/lib/utils/compatibility.js b/lib/utils/compatibility.js index bb81e8ba..a1909641 100644 --- a/lib/utils/compatibility.js +++ b/lib/utils/compatibility.js @@ -7,6 +7,7 @@ var DEFAULTS = { }, properties: { backgroundClipMerging: false, // background-clip to shorthand + backgroundOriginMerging: false, // background-origin to shorthand backgroundSizeMerging: false, // background-size to shorthand colors: true, // any kind of color transformations, like `#ff00ff` to `#f0f` or `#fff` into `red` iePrefixHack: false, // underscore / asterisk prefix hacks on IE @@ -37,6 +38,7 @@ var DEFAULTS = { }, properties: { backgroundClipMerging: false, + backgroundOriginMerging: false, backgroundSizeMerging: false, colors: true, iePrefixHack: true, @@ -67,6 +69,7 @@ var DEFAULTS = { }, properties: { backgroundClipMerging: false, + backgroundOriginMerging: false, backgroundSizeMerging: false, colors: true, iePrefixHack: true, diff --git a/test/integration-test.js b/test/integration-test.js index 33032d55..435bd565 100644 --- a/test/integration-test.js +++ b/test/integration-test.js @@ -2106,16 +2106,6 @@ title']{display:block}", 'div{background:content-box #000}' ] }), - 'background-origin': cssContext({ - 'inside background shorthand': [ - 'div{background:content-box #000}', - 'div{background:content-box #000}' - ], - 'into background shorthand': [ - 'div{background:#000;background-origin:content-box}', - 'div{background:content-box border-box #000}' - ] - }), 'background size with +properties.backgroundSizeMerging': cssContext({ 'with background-size property': [ 'a{background:none;background-image:url(1.png);background-size:28px 28px}', diff --git a/test/properties/override-compacting-test.js b/test/properties/override-compacting-test.js index 1117ad4d..052aaf55 100644 --- a/test/properties/override-compacting-test.js +++ b/test/properties/override-compacting-test.js @@ -108,6 +108,23 @@ vows.describe(optimize) ]); } }, + 'shorthand then longhand - disabled background origin merging': { + 'topic': 'p{background:__ESCAPED_URL_CLEAN_CSS0__;background-origin:border-box}', + 'into': function (topic) { + assert.deepEqual(_optimize(topic, { properties: { backgroundOriginMerging: false } }), [ + [['background', false , false], ['__ESCAPED_URL_CLEAN_CSS0__']], + [['background-origin', false , false], ['border-box']] + ]); + } + }, + 'shorthand then longhand - enabled background origin merging': { + 'topic': 'p{background:__ESCAPED_URL_CLEAN_CSS0__;background-origin:border-box}', + 'into': function (topic) { + assert.deepEqual(_optimize(topic, { properties: { backgroundOriginMerging: true } }), [ + [['background', false , false], ['__ESCAPED_URL_CLEAN_CSS0__'], ['border-box']] + ]); + } + }, 'shorthand then longhand - non mergeable value': { 'topic': 'p{background:__ESCAPED_URL_CLEAN_CSS0__;background-color:none}', 'into': function (topic) { diff --git a/test/utils/compatibility-test.js b/test/utils/compatibility-test.js index 9a9d08a9..c72cbd61 100644 --- a/test/utils/compatibility-test.js +++ b/test/utils/compatibility-test.js @@ -12,6 +12,7 @@ vows.describe(Compatibility) assert.isTrue(options.colors.opacity); assert.isTrue(options.properties.colors); assert.isFalse(options.properties.backgroundClipMerging); + assert.isFalse(options.properties.backgroundOriginMerging); assert.isFalse(options.properties.backgroundSizeMerging); assert.isFalse(options.properties.iePrefixHack); assert.isFalse(options.properties.ieSuffixHack); @@ -46,6 +47,7 @@ vows.describe(Compatibility) 'gets merged options': function(options) { assert.isTrue(options.colors.opacity); assert.isFalse(options.properties.backgroundClipMerging); + assert.isFalse(options.properties.backgroundOriginMerging); assert.isFalse(options.properties.backgroundSizeMerging); assert.isTrue(options.properties.colors); assert.isFalse(options.properties.iePrefixHack); @@ -74,6 +76,7 @@ vows.describe(Compatibility) 'gets template options': function(options) { assert.isFalse(options.colors.opacity); assert.isFalse(options.properties.backgroundClipMerging); + assert.isFalse(options.properties.backgroundOriginMerging); assert.isFalse(options.properties.backgroundSizeMerging); assert.isTrue(options.properties.colors); assert.isTrue(options.properties.iePrefixHack); @@ -101,6 +104,7 @@ vows.describe(Compatibility) 'gets template options': function(options) { assert.isFalse(options.colors.opacity); assert.isFalse(options.properties.backgroundClipMerging); + assert.isFalse(options.properties.backgroundOriginMerging); assert.isFalse(options.properties.backgroundSizeMerging); assert.isTrue(options.properties.colors); assert.isTrue(options.properties.iePrefixHack); @@ -138,6 +142,7 @@ vows.describe(Compatibility) 'gets calculated options': function(options) { assert.isTrue(options.colors.opacity); assert.isFalse(options.properties.backgroundClipMerging); + assert.isFalse(options.properties.backgroundOriginMerging); assert.isFalse(options.properties.backgroundSizeMerging); assert.isTrue(options.properties.colors); assert.isFalse(options.properties.iePrefixHack); @@ -166,6 +171,7 @@ vows.describe(Compatibility) assert.isTrue(options.colors.opacity); assert.isTrue(options.properties.colors); assert.isFalse(options.properties.backgroundClipMerging); + assert.isFalse(options.properties.backgroundOriginMerging); assert.isFalse(options.properties.backgroundSizeMerging); assert.isTrue(options.properties.iePrefixHack); assert.isFalse(options.properties.ieSuffixHack); @@ -193,6 +199,7 @@ vows.describe(Compatibility) assert.isTrue(options.colors.opacity); assert.isTrue(options.properties.colors); assert.isFalse(options.properties.backgroundClipMerging); + assert.isFalse(options.properties.backgroundOriginMerging); assert.isFalse(options.properties.backgroundSizeMerging); assert.isTrue(options.properties.iePrefixHack); assert.isFalse(options.properties.ieSuffixHack); -- 2.34.1