Fixes #743 - background shorthand and source maps.
authorJakub Pawlowicz <contact@jakubpawlowicz.com>
Fri, 1 Apr 2016 19:55:15 +0000 (21:55 +0200)
committerJakub Pawlowicz <contact@jakubpawlowicz.com>
Fri, 1 Apr 2016 20:49:42 +0000 (22:49 +0200)
There was an edge case when background-size was incorrectly
parsed as background-position.

History.md
lib/properties/break-up.js
test/source-map-test.js

index dbc0864..eaf435e 100644 (file)
@@ -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)
index 9add0ef..b48b146 100644 (file)
@@ -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] == '/') {
index 21bcfdd..1fb5003 100644 (file)
@@ -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}');