From: Jakub Pawlowicz Date: Sat, 13 Dec 2014 10:42:56 +0000 (+0000) Subject: Fixes #304 - background position merging. X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=834ecc7bb9e0914a496c17c88e42ccfb01b572f5;p=clean-css.git Fixes #304 - background position merging. * Background positions with more than 2 components were treated incorrectly. --- diff --git a/History.md b/History.md index 0953d743..9ce19b32 100644 --- a/History.md +++ b/History.md @@ -24,6 +24,7 @@ * Fixed issue [#373](https://github.com/GoalSmashers/clean-css/issues/373) - proper background shorthand merging. * Fixed issue [#395](https://github.com/GoalSmashers/clean-css/issues/395) - unescaped brackets in data URIs. * Fixed issue [#403](https://github.com/GoalSmashers/clean-css/issues/403) - tracking input files in source maps. +* Refixed issue [#304](https://github.com/GoalSmashers/clean-css/issues/304) - background position merging. [2.2.19 / 2014-11-20](https://github.com/jakubpawlowicz/clean-css/compare/v2.2.18...v2.2.19) ================== diff --git a/lib/properties/processable.js b/lib/properties/processable.js index 913108a4..c1e256e3 100644 --- a/lib/properties/processable.js +++ b/lib/properties/processable.js @@ -172,6 +172,7 @@ module.exports = (function () { var repeat = result[3]; var attachment = result[4]; var color = result[5]; + var positionSet = false; // Take care of inherit if (token.value === 'inherit') { @@ -206,14 +207,13 @@ module.exports = (function () { i -= 2; } else if (parts[i - 1] == '/') { size.value = currentPart; - position.value = previousPart; - i--; } else { - position.value = previousPart + ' ' + currentPart; - i--; + position.value = currentPart + (positionSet ? ' ' + position.value : ''); + positionSet = true; } } else { - position.value = currentPart; + position.value = currentPart + (positionSet ? ' ' + position.value : ''); + positionSet = true; } } else if (validator.isValidBackgroundPositionAndSize(currentPart)) { var sizeValue = new Splitter('/').split(currentPart); diff --git a/test/data/issue-304-2-min.css b/test/data/issue-304-2-min.css new file mode 100644 index 00000000..919eb5b9 --- /dev/null +++ b/test/data/issue-304-2-min.css @@ -0,0 +1,2 @@ +.one{background:url(one.png) right 10px top 10px no-repeat,linear-gradient(0deg,#efefef 0,#fff 100%)} +.two{background:url(two.png) right 9px top 15px/9px 7px no-repeat,linear-gradient(-179deg,#FFF 0,#F9F9F9 100%)} diff --git a/test/data/issue-304-2.css b/test/data/issue-304-2.css new file mode 100644 index 00000000..02f068cb --- /dev/null +++ b/test/data/issue-304-2.css @@ -0,0 +1,6 @@ +.one { + background: url(one.png) no-repeat right 10px top 10px, linear-gradient(0deg, #efefef 0%, #ffffff 100%); +} +.two { + background: url(two.png) no-repeat right 9px top 15px/9px 7px, linear-gradient(-179deg, #FFFFFF 0%, #F9F9F9 100%); +} diff --git a/test/integration-test.js b/test/integration-test.js index 8f358f13..4993ed68 100644 --- a/test/integration-test.js +++ b/test/integration-test.js @@ -2191,8 +2191,8 @@ title']{display:block}", ] }), 'background size with -properties.backgroundSizeMerging': cssContext({ - 'standard': 'div{background:url(image.png) no-repeat center;background-size:cover}', - 'prefix': 'div{-webkit-background:url(image.png) no-repeat center;-webkit-background-size:cover}' + 'standard': 'div{background:url(image.png) center no-repeat;background-size:cover}', + 'prefix': 'div{-webkit-background:url(image.png) center no-repeat;-webkit-background-size:cover}' }, { compatibility: '-properties.backgroundSizeMerging' }), 'multiple backgrounds': cssContext({ 'should not produce longer values': 'p{background:no-repeat;background-position:100% 0,0 100%,100% 100%,50% 50%}'