upgrade dependencies
authoralexlamsl <alexlamsl@gmail.com>
Sun, 25 Dec 2016 02:36:23 +0000 (10:36 +0800)
committeralexlamsl <alexlamsl@gmail.com>
Mon, 23 Jan 2017 17:28:23 +0000 (01:28 +0800)
clean-css 4.0.0

README.md
package.json
src/htmlminifier.js
tests/minifier.js

index 4bb4900..e34b70f 100644 (file)
--- a/README.md
+++ b/README.md
@@ -58,7 +58,7 @@ Most of the options are disabled by default.
 | `includeAutoGeneratedTags`     | Insert tags generated by HTML parser | `true` |
 | `keepClosingSlash`             | Keep the trailing slash on singleton elements | `false` |
 | `maxLineLength`                | Specify a maximum line length. Compressed output will be split by newlines at valid HTML split-points |
-| `minifyCSS`                    | Minify CSS in style elements and style attributes (uses [clean-css](https://github.com/jakubpawlowicz/clean-css)). `advanced` optimisations are disabled by default | `false` (could be `true`, `Object`, `Function(text)`) |
+| `minifyCSS`                    | Minify CSS in style elements and style attributes (uses [clean-css](https://github.com/jakubpawlowicz/clean-css)) | `false` (could be `true`, `Object`, `Function(text)`) |
 | `minifyJS`                     | Minify JavaScript in script elements and event attributes (uses [UglifyJS](https://github.com/mishoo/UglifyJS2)) | `false` (could be `true`, `Object`, `Function(text, inline)`) |
 | `minifyURLs`                   | Minify URLs in various attributes (uses [relateurl](https://github.com/stevenvachon/relateurl)) | `false` (could be `String`, `Object`, `Function(text)`) |
 | `preserveLineBreaks`           | Always collapse to 1 line break (never remove it entirely) when whitespace between tags include a line break. Must be used in conjunction with `collapseWhitespace=true` | `false` |
index 38b8091..55a229e 100644 (file)
@@ -55,7 +55,7 @@
   },
   "dependencies": {
     "camel-case": "3.0.x",
-    "clean-css": "3.4.x",
+    "clean-css": "4.0.x",
     "commander": "2.9.x",
     "he": "1.1.x",
     "ncname": "1.0.x",
index f9841bc..431281b 100644 (file)
@@ -702,17 +702,12 @@ function processOptions(options) {
     if (typeof minifyCSS !== 'object') {
       minifyCSS = {};
     }
-    if (typeof minifyCSS.advanced === 'undefined') {
-      minifyCSS.advanced = false;
-    }
     options.minifyCSS = function(text) {
       text = text.replace(/(url\s*\(\s*)("|'|)(.*?)\2(\s*\))/ig, function(match, prefix, quote, url, suffix) {
         return prefix + quote + options.minifyURLs(url) + quote + suffix;
       });
-      var start = text.match(/^\s*<!--/);
-      var style = start ? text.slice(start[0].length).replace(/-->\s*$/, '') : text;
       try {
-        return new CleanCSS(minifyCSS).minify(style).styles;
+        return new CleanCSS(minifyCSS).minify(text).styles;
       }
       catch (err) {
         options.log(err);
index 77c63be..dd7ec27 100644 (file)
@@ -595,7 +595,7 @@ QUnit.test('remove comments from styles', function(assert) {
 
   input = '<style>p.h{background:red}<!--\np.i{background:red}\n-->p.j{background:red}</style>';
   assert.equal(minify(input), input);
-  output = '<style>p.h{background:red}<!-- p.i{background:red}-->p.j{background:red}</style>';
+  output = '<style>p.h{background:red}p.i{background:red}p.j{background:red}</style>';
   assert.equal(minify(input, { minifyCSS: true }), output);
 
   input = '<style type="text/css"><!-- p { color: red } --></style>';
@@ -658,37 +658,37 @@ QUnit.test('remove CDATA sections from scripts/styles', function(assert) {
 
   input = '<style><![CDATA[\np.a{background:red}\n]]></style>';
   assert.equal(minify(input), input);
-  output = '<style><![CDATA[ p.a{background:red}\n]]></style>';
+  output = '<style></style>';
   assert.equal(minify(input, { minifyCSS: true }), output);
 
   input = '<style><![CDATA[p.b{background:red}]]></style>';
   assert.equal(minify(input), input);
-  output = '<style><![CDATA[p.b{background:red}]]></style>';
+  output = '<style></style>';
   assert.equal(minify(input, { minifyCSS: true }), output);
 
   input = '<style><![CDATA[p.c{background:red}\n]]></style>';
   assert.equal(minify(input), input);
-  output = '<style><![CDATA[p.c{background:red}\n]]></style>';
+  output = '<style></style>';
   assert.equal(minify(input, { minifyCSS: true }), output);
 
   input = '<style><![CDATA[\np.d{background:red}]]></style>';
   assert.equal(minify(input), input);
-  output = '<style><![CDATA[ p.d{background:red}]]></style>';
+  output = '<style></style>';
   assert.equal(minify(input, { minifyCSS: true }), output);
 
   input = '<style><![CDATA[p.e{background:red}\np.f{background:red}\np.g{background:red}]]></style>';
   assert.equal(minify(input), input);
-  output = '<style><![CDATA[p.e{background:red}p.f{background:red}p.g{background:red}]]></style>';
+  output = '<style>p.f{background:red}p.g{background:red}</style>';
   assert.equal(minify(input, { minifyCSS: true }), output);
 
   input = '<style>p.h{background:red}<![CDATA[\np.i{background:red}\n]]>p.j{background:red}</style>';
   assert.equal(minify(input), input);
-  output = '<style>p.h{background:red}<![CDATA[ p.i{background:red}]]>p.j{background:red}</style>';
+  output = '<style>p.h{background:red}]]>p.j{background:red}</style>';
   assert.equal(minify(input, { minifyCSS: true }), output);
 
   input = '<style>/* <![CDATA[ */p { color: red } // ]]></style>';
   assert.equal(minify(input), input);
-  output = '<style>p{color:red} // ]]></style>';
+  output = '<style>p{color:red}</style>';
   assert.equal(minify(input, { minifyCSS: true }), output);
 
   input = '<style type="text/html">\n<div>\n</div>\n<![CDATA[ aa ]]>\n</style>';
@@ -2252,6 +2252,26 @@ QUnit.test('url attribute minification', function(assert) {
     minifyURLs: { site: 'http://website.com/foo bar/' }
   }), output);
 
+  input = '<style>body { background: url("http://website.com/foo bar/(baz)/bg.png") }</style>';
+  assert.equal(minify(input, { minifyURLs: { site: 'http://website.com/' } }), input);
+  assert.equal(minify(input, { minifyURLs: { site: 'http://website.com/foo%20bar/' } }), input);
+  assert.equal(minify(input, { minifyURLs: { site: 'http://website.com/foo%20bar/(baz)/' } }), input);
+  output = '<style>body{background:url("foo%20bar/(baz)/bg.png")}</style>';
+  assert.equal(minify(input, {
+    minifyCSS: true,
+    minifyURLs: { site: 'http://website.com/' }
+  }), output);
+  output = '<style>body{background:url("(baz)/bg.png")}</style>';
+  assert.equal(minify(input, {
+    minifyCSS: true,
+    minifyURLs: { site: 'http://website.com/foo%20bar/' }
+  }), output);
+  output = '<style>body{background:url(bg.png)}</style>';
+  assert.equal(minify(input, {
+    minifyCSS: true,
+    minifyURLs: { site: 'http://website.com/foo%20bar/(baz)/' }
+  }), output);
+
   input = '<img src="http://cdn.site.com/foo.png">';
   output = '<img src="//cdn.site.com/foo.png">';
   assert.equal(minify(input, { minifyURLs: { site: 'http://site.com/' } }), output);