aboutsummaryrefslogtreecommitdiff
path: root/node_modules/html-minifier/src/htmlminifier.js
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/html-minifier/src/htmlminifier.js')
-rw-r--r--node_modules/html-minifier/src/htmlminifier.js36
1 files changed, 14 insertions, 22 deletions
diff --git a/node_modules/html-minifier/src/htmlminifier.js b/node_modules/html-minifier/src/htmlminifier.js
index f7917cd4a..5b9c9cf32 100644
--- a/node_modules/html-minifier/src/htmlminifier.js
+++ b/node_modules/html-minifier/src/htmlminifier.js
@@ -626,13 +626,11 @@ function processOptions(options) {
options.log = identity;
}
- var defaultTesters = ['canCollapseWhitespace', 'canTrimWhitespace'];
- for (var i = 0, len = defaultTesters.length; i < len; i++) {
- if (!options[defaultTesters[i]]) {
- options[defaultTesters[i]] = function() {
- return false;
- };
- }
+ if (!options.canCollapseWhitespace) {
+ options.canCollapseWhitespace = canCollapseWhitespace;
+ }
+ if (!options.canTrimWhitespace) {
+ options.canTrimWhitespace = canTrimWhitespace;
}
if (!('ignoreCustomComments' in options)) {
@@ -676,23 +674,17 @@ function processOptions(options) {
if (typeof minifyJS !== 'object') {
minifyJS = {};
}
- minifyJS.fromString = true;
(minifyJS.parse || (minifyJS.parse = {})).bare_returns = false;
options.minifyJS = function(text, inline) {
var start = text.match(/^\s*<!--.*/);
var code = start ? text.slice(start[0].length).replace(/\n\s*-->\s*$/, '') : text;
- try {
- minifyJS.parse.bare_returns = inline;
- code = UglifyJS.minify(code, minifyJS).code;
- if (/;$/.test(code)) {
- code = code.slice(0, -1);
- }
- return code;
- }
- catch (err) {
- options.log(err);
+ minifyJS.parse.bare_returns = inline;
+ var result = UglifyJS.minify(code, minifyJS);
+ if (result.error) {
+ options.log(result.error);
return text;
}
+ return result.code.replace(/;$/, '');
};
}
@@ -760,7 +752,7 @@ function createSortFns(value, options, uidIgnore, uidAttr) {
for (var i = 0, len = attrs.length; i < len; i++) {
var attr = attrs[i];
if (classChain && (options.caseSensitive ? attr.name : attr.name.toLowerCase()) === 'class') {
- classChain.add(trimWhitespace(attr.value).split(/\s+/).filter(shouldSkipUIDs));
+ classChain.add(trimWhitespace(attr.value).split(/[ \t\n\f\r]+/).filter(shouldSkipUIDs));
}
else if (options.processScripts && attr.name.toLowerCase() === 'type') {
currentTag = tag;
@@ -808,7 +800,7 @@ function createSortFns(value, options, uidIgnore, uidAttr) {
if (classChain) {
var sorter = classChain.createSorter();
options.sortClassName = function(value) {
- return sorter.sort(value.split(/\s+/)).join(' ');
+ return sorter.sort(value.split(/[ \n\f\r]+/)).join(' ');
};
}
}
@@ -900,11 +892,11 @@ function minify(value, options, partialMarkup) {
}
function _canCollapseWhitespace(tag, attrs) {
- return canCollapseWhitespace(tag) || options.canCollapseWhitespace(tag, attrs);
+ return options.canCollapseWhitespace(tag, attrs, canCollapseWhitespace);
}
function _canTrimWhitespace(tag, attrs) {
- return canTrimWhitespace(tag) || options.canTrimWhitespace(tag, attrs);
+ return options.canTrimWhitespace(tag, attrs, canTrimWhitespace);
}
function removeStartTag() {