Fixes #580 - mixed import processing.
authorJakub Pawlowicz <contact@jakubpawlowicz.com>
Fri, 29 May 2015 08:46:02 +0000 (09:46 +0100)
committerJakub Pawlowicz <contact@jakubpawlowicz.com>
Fri, 29 May 2015 08:48:14 +0000 (09:48 +0100)
This is related to #570 when a no-url imports are mixed with url ones.

History.md
lib/urls/reduce.js
test/module-test.js

index b6ad824..5259656 100644 (file)
@@ -19,6 +19,7 @@
 * 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.
+* Fixed issue [#580](https://github.com/jakubpawlowicz/clean-css/issues/580) - mixed `@import` processing.
 * Fixed issue [#582](https://github.com/jakubpawlowicz/clean-css/issues/582) - overriding with prefixed values.
 * Fixed issue [#583](https://github.com/jakubpawlowicz/clean-css/issues/583) - URL quoting for SVG data.
 
index 84555c8..ded0bf7 100644 (file)
@@ -99,8 +99,10 @@ function byImport(data, context, callback) {
     tempData.push(data.substring(cursor, nextStart));
 
     nextEnd = data.indexOf(withQuote, nextStart + 1);
-    if (nextEnd == -1)
+    if (nextEnd == -1) {
+      cursor = nextStart;
       break;
+    }
 
     var url = data.substring(nextStart, nextEnd + 1);
     callback(url, tempData);
index 0223987..2c1f64d 100644 (file)
@@ -578,6 +578,18 @@ vows.describe('module tests').addBatch({
         'should give right output': function (minified) {
           assert.equal(minified.styles, '.one{color:red}.three{color:#0f0}.four{color:#00f}.two{color:#fff}');
         }
+      },
+      'with two import URLs when one is a string plus a callback 123': {
+        'topic': function () {
+          new CleanCSS().minify({
+            'main.css': {
+              styles: '@import "test/fixtures/partials/one.css";\n@import url(test/fixtures/partials/three.css);'
+            }
+          }, this.callback);
+        },
+        'should give right output': function (error, minified) {
+          assert.equal(minified.styles, '.one{color:red}.three{background-image:url(test/fixtures/partials/extra/down.gif)}');
+        }
       }
     },
     'with remote paths': {