From: Jakub Pawlowicz Date: Fri, 1 Apr 2016 19:55:15 +0000 (+0200) Subject: Fixes #743 - background shorthand and source maps. X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=dee37a7c31cff80bc0c187ad4daccd7b9af92c4a;p=clean-css.git Fixes #743 - background shorthand and source maps. There was an edge case when background-size was incorrectly parsed as background-position. --- diff --git a/History.md b/History.md index dbc08647..eaf435eb 100644 --- a/History.md +++ b/History.md @@ -7,6 +7,7 @@ ================== * Fixed issue [#741](https://github.com/jakubpawlowicz/clean-css/issues/741) - HTTP proxy with HTTPS inlining. +* Fixed issue [#743](https://github.com/jakubpawlowicz/clean-css/issues/743) - background shorthand and source maps. * Fixed issue [#745](https://github.com/jakubpawlowicz/clean-css/issues/745) - matching mixed case `!important`. [3.4.10 / 2016-02-29](https://github.com/jakubpawlowicz/clean-css/compare/v3.4.9...v3.4.10) diff --git a/lib/properties/break-up.js b/lib/properties/break-up.js index 9add0ef7..b48b146d 100644 --- a/lib/properties/break-up.js +++ b/lib/properties/break-up.js @@ -83,7 +83,7 @@ function background(property, compactable, validator) { // NOTE: we do this slicing as value may contain metadata too, like for source maps size.value = [[twoParts.pop()].concat(previousValue.slice(1)), value]; values[i - 1] = [twoParts.pop()].concat(previousValue.slice(1)); - } else if (i > 1 && values[i - 2] == '/') { + } else if (i > 1 && values[i - 2][0] == '/') { size.value = [previousValue, value]; i -= 2; } else if (previousValue[0] == '/') { diff --git a/test/source-map-test.js b/test/source-map-test.js index 21bcfddc..1fb5003d 100644 --- a/test/source-map-test.js +++ b/test/source-map-test.js @@ -52,6 +52,14 @@ vows.describe('source-map') assert.equal(minified.styles, 'a{background:url(image.png) 0 0/100% no-repeat}'); } }, + 'background position and size without image': { + 'topic': function () { + return new CleanCSS({ sourceMap: true }).minify('a{background: 50% 50% / 100% auto no-repeat currentColor}'); + }, + 'gets right output': function (minified) { + assert.equal(minified.styles, 'a{background:50% 50%/100% auto no-repeat currentColor}'); + } + }, 'important': { 'topic': function () { return new CleanCSS({ sourceMap: true }).minify('@font-face{font-family:si}a{font-family:si!important}');