html-minifier 3.5.5 → 3.5.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2010-2016 Juriy "kangax" Zaytsev
1
+ Copyright (c) 2010-2018 Juriy "kangax" Zaytsev
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person
4
4
  obtaining a copy of this software and associated documentation
package/README.md CHANGED
@@ -22,19 +22,19 @@ How does HTMLMinifier compare to other solutions — [HTML Minifier from Will Pe
22
22
 
23
23
  | Site | Original size *(KB)* | HTMLMinifier | minimize | Will Peavy | htmlcompressor.com |
24
24
  | ---------------------------------------------------------------------------- |:--------------------:| ------------:| --------:| ----------:| ------------------:|
25
- | [Google](https://www.google.com/) | 45 | **42** | 45 | 47 | 45 |
26
- | [HTMLMinifier](https://github.com/kangax/html-minifier) | 133 | **104** | 112 | 116 | 111 |
27
- | [Amazon](https://www.amazon.co.uk/) | 203 | **171** | 195 | 199 | n/a |
28
- | [New York Times](https://www.nytimes.com/) | 233 | **158** | 182 | 178 | 166 |
29
- | [Stack Overflow](https://stackoverflow.com/) | 239 | **186** | 195 | 203 | 192 |
25
+ | [Google](https://www.google.com/) | 46 | **43** | 46 | 47 | 46 |
26
+ | [Twitter](https://twitter.com/) | 127 | **94** | 119 | 136 | 119 |
27
+ | [HTMLMinifier](https://github.com/kangax/html-minifier) | 135 | **105** | 113 | 118 | 113 |
28
+ | [New York Times](https://www.nytimes.com/) | 232 | **161** | 181 | 178 | 166 |
29
+ | [Stack Overflow](https://stackoverflow.com/) | 250 | **196** | 205 | 214 | 203 |
30
+ | [BBC](https://www.bbc.co.uk/) | 270 | **220** | 262 | 268 | 252 |
30
31
  | [Bootstrap CSS](https://getbootstrap.com/docs/3.3/css/) | 272 | **260** | 269 | 229 | 269 |
31
- | [BBC](https://www.bbc.co.uk/) | 279 | **229** | 271 | 278 | 262 |
32
- | [Twitter](https://twitter.com/) | 298 | **223** | 263 | 287 | 263 |
33
- | [Wikipedia](https://en.wikipedia.org/wiki/President_of_the_United_States) | 469 | **437** | 453 | 468 | 453 |
34
- | [NBC](https://www.nbc.com/) | 665 | **627** | 661 | 664 | n/a |
32
+ | [Amazon](https://www.amazon.co.uk/) | 392 | **336** | 377 | 390 | n/a |
33
+ | [Wikipedia](https://en.wikipedia.org/wiki/President_of_the_United_States) | 473 | **442** | 458 | 473 | 457 |
34
+ | [NBC](https://www.nbc.com/) | 646 | **613** | 642 | 646 | n/a |
35
35
  | [Eloquent Javascript](https://eloquentjavascript.net/1st_edition/print.html) | 870 | **815** | 840 | 864 | n/a |
36
- | [ES6 table](https://kangax.github.io/compat-table/es6/) | 4228 | **3586** | 3999 | n/a | n/a |
37
- | [ES6 draft](https://tc39.github.io/ecma262/) | 5701 | **5087** | 5236 | n/a | n/a |
36
+ | [ES6 table](https://kangax.github.io/compat-table/es6/) | 4579 | **3898** | 4333 | n/a | n/a |
37
+ | [ES6 draft](https://tc39.github.io/ecma262/) | 5871 | **5225** | 5382 | n/a | n/a |
38
38
 
39
39
  ## Options Quick Reference
40
40
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "html-minifier",
3
3
  "description": "Highly configurable, well-tested, JavaScript-based HTML minifier.",
4
- "version": "3.5.5",
4
+ "version": "3.5.9",
5
5
  "keywords": [
6
6
  "cli",
7
7
  "compress",
@@ -56,27 +56,27 @@
56
56
  "dependencies": {
57
57
  "camel-case": "3.0.x",
58
58
  "clean-css": "4.1.x",
59
- "commander": "2.11.x",
59
+ "commander": "2.14.x",
60
60
  "he": "1.1.x",
61
61
  "ncname": "1.0.x",
62
62
  "param-case": "2.1.x",
63
63
  "relateurl": "0.2.x",
64
- "uglify-js": "3.1.x"
64
+ "uglify-js": "3.3.x"
65
65
  },
66
66
  "devDependencies": {
67
67
  "grunt": "1.0.x",
68
68
  "grunt-browserify": "5.2.x",
69
- "grunt-contrib-uglify": "3.1.x",
69
+ "grunt-contrib-uglify": "3.3.x",
70
70
  "gruntify-eslint": "4.0.x",
71
71
  "phantomjs-prebuilt": "2.1.x",
72
- "qunitjs": "2.x"
72
+ "qunit": "2.x"
73
73
  },
74
74
  "benchmarkDependencies": {
75
75
  "brotli": "1.3.x",
76
- "chalk": "2.1.x",
76
+ "chalk": "2.3.x",
77
77
  "cli-table": "0.3.x",
78
78
  "lzma": "2.3.x",
79
- "minimize": "2.1.x",
79
+ "minimize": "2.2.x",
80
80
  "progress": "2.0.x"
81
81
  },
82
82
  "files": [
@@ -67,7 +67,7 @@ function collapseWhitespace(str, options, trimLeft, trimRight, collapseAll) {
67
67
 
68
68
  var createMapFromString = utils.createMapFromString;
69
69
  // non-empty tags that will maintain whitespace around them
70
- var inlineTags = createMapFromString('a,abbr,acronym,b,bdi,bdo,big,button,cite,code,del,dfn,em,font,i,ins,kbd,mark,math,nobr,q,rt,rp,s,samp,small,span,strike,strong,sub,sup,svg,time,tt,u,var');
70
+ var inlineTags = createMapFromString('a,abbr,acronym,b,bdi,bdo,big,button,cite,code,del,dfn,em,font,i,ins,kbd,label,mark,math,nobr,object,q,rt,rp,s,samp,select,small,span,strike,strong,sub,sup,svg,textarea,time,tt,u,var');
71
71
  // non-empty tags that will maintain whitespace within them
72
72
  var inlineTextTags = createMapFromString('a,abbr,acronym,b,big,del,em,font,i,ins,kbd,mark,nobr,s,samp,small,span,strike,strong,sub,sup,time,tt,u,var');
73
73
  // self-closing tags that will maintain whitespace around them
@@ -283,7 +283,7 @@ function cleanAttributeValue(tag, attrName, attrValue, options, attrs) {
283
283
  attrValue = trimWhitespace(attrValue);
284
284
  if (attrValue) {
285
285
  if (/;$/.test(attrValue) && !/&#?[0-9a-zA-Z]+;$/.test(attrValue)) {
286
- attrValue = attrValue.replace(/\s*;$/, '');
286
+ attrValue = attrValue.replace(/\s*;$/, ';');
287
287
  }
288
288
  attrValue = unwrapInlineCSS(options.minifyCSS(wrapInlineCSS(attrValue)));
289
289
  }
@@ -996,11 +996,13 @@ function minify(value, options, partialMarkup) {
996
996
  if (!stackNoTrimWhitespace.length) {
997
997
  squashTrailingWhitespace(tag);
998
998
  }
999
- if (!_canTrimWhitespace(tag, attrs) || stackNoTrimWhitespace.length) {
1000
- stackNoTrimWhitespace.push(tag);
1001
- }
1002
- if (!_canCollapseWhitespace(tag, attrs) || stackNoCollapseWhitespace.length) {
1003
- stackNoCollapseWhitespace.push(tag);
999
+ if (!unary) {
1000
+ if (!_canTrimWhitespace(tag, attrs) || stackNoTrimWhitespace.length) {
1001
+ stackNoTrimWhitespace.push(tag);
1002
+ }
1003
+ if (!_canCollapseWhitespace(tag, attrs) || stackNoCollapseWhitespace.length) {
1004
+ stackNoCollapseWhitespace.push(tag);
1005
+ }
1004
1006
  }
1005
1007
  }
1006
1008
 
package/src/htmlparser.js CHANGED
@@ -70,7 +70,7 @@ var inline = makeMap('a,abbr,acronym,applet,b,basefont,bdo,big,br,button,cite,co
70
70
 
71
71
  // Elements that you can, intentionally, leave open
72
72
  // (and which close themselves)
73
- var closeSelf = makeMap('colgroup,dd,dt,li,options,p,td,tfoot,th,thead,tr,source');
73
+ var closeSelf = makeMap('colgroup,dd,dt,li,option,p,td,tfoot,th,thead,tr,source');
74
74
 
75
75
  // Attributes that have their values filled in disabled='disabled'
76
76
  var fillAttrs = makeMap('checked,compact,declare,defer,disabled,ismap,multiple,nohref,noresize,noshade,nowrap,readonly,selected');
@@ -270,7 +270,7 @@ function HTMLParser(html, handler) {
270
270
  parseEndTag('', lastTag);
271
271
  }
272
272
 
273
- if (!handler.html5) {
273
+ if (!handler.html5 && !inline(tagName)) {
274
274
  while (lastTag && inline(lastTag)) {
275
275
  parseEndTag('', lastTag);
276
276
  }