within a )
if (options.collapseWhitespace) {
if (!stackNoTrimWhitespace.length) {
- squashTrailingWhitespace(data.tag, insertionIndex);
+ squashTrailingWhitespace(data.tag);
}
if (!data.unary) {
if (!_canTrimWhitespace(data.tag, data.attrs) || stackNoTrimWhitespace.length) {
@@ -1157,7 +1125,7 @@ function minify(value, options, partialMarkup, cb) {
var openTag = '<' + data.tag;
var hasUnarySlash = data.unarySlash && options.keepClosingSlash;
- buffer.splice(insertionIndex++, 0, openTag);
+ buffer.push(openTag);
if (options.sortAttributes) {
options.sortAttributes(data.tag, data.attrs);
@@ -1190,20 +1158,18 @@ function minify(value, options, partialMarkup, cb) {
// All attributes are now normalize.
if (parts.length > 0) {
- buffer.splice.apply(buffer, [insertionIndex, 0, ' '].concat(parts));
- insertionIndex += 1 + parts.length;
+ buffer.push(' ');
+ buffer.push.apply(buffer, parts);
}
// start tag must never be omitted if it has any attributes
else if (optional && optionalStartTags(data.tag)) {
optionalStartTag = data.tag;
}
- // Remove the last inserted element, modify it and put it back.
- var lastElem = buffer.splice(--insertionIndex, 1)[0];
- buffer.splice(insertionIndex++, 0, lastElem + (hasUnarySlash ? '/' : '') + '>');
+ buffer.push(buffer.pop() + (hasUnarySlash ? '/' : '') + '>');
if (data.autoGenerated && !options.includeAutoGeneratedTags) {
- insertionIndex -= removeStartTag(insertionIndex);
+ removeStartTag();
optionalStartTag = '';
}
@@ -1219,18 +1185,8 @@ function minify(value, options, partialMarkup, cb) {
);
},
end: function(tag, attrs, autoGenerated) {
- var placeholder = new Placeholder(); // Some unique reference.
- buffer.push(placeholder);
-
asyncTasks.push(
new AsyncTask(function(data, cb) {
- // The index of the placeholder may not be the same as where it
- // was originally inserted at; therefore we need to search for it.
- var insertionIndex = buffer.indexOf(placeholder);
-
- // Remove the placeholder.
- buffer.splice(insertionIndex, 1);
-
var lowerTag = data.tag.toLowerCase();
if (lowerTag === 'svg') {
options = Object.getPrototypeOf(options);
@@ -1245,7 +1201,7 @@ function minify(value, options, partialMarkup, cb) {
}
}
else {
- squashTrailingWhitespace('/' + data.tag, insertionIndex);
+ squashTrailingWhitespace('/' + data.tag);
}
if (stackNoCollapseWhitespace.length &&
data.tag === stackNoCollapseWhitespace[stackNoCollapseWhitespace.length - 1]) {
@@ -1262,7 +1218,7 @@ function minify(value, options, partialMarkup, cb) {
if (options.removeOptionalTags) {
// , or may be omitted if the element is empty
if (isElementEmpty && topLevelTags(optionalStartTag)) {
- insertionIndex -= removeStartTag(insertionIndex);
+ removeStartTag();
}
optionalStartTag = '';
// or may be omitted if not followed by comment
@@ -1270,14 +1226,14 @@ function minify(value, options, partialMarkup, cb) {
// may be omitted if no more content in non- parent
// except for or , end tags may be omitted if no more content in parent element
if (htmlTags(data.tag) && optionalEndTag && !trailingTags(optionalEndTag) && (optionalEndTag !== 'p' || !pInlineTags(data.tag))) {
- insertionIndex -= removeEndTag(insertionIndex);
+ removeEndTag();
}
optionalEndTag = optionalEndTags(data.tag) ? data.tag : '';
}
if (options.removeEmptyElements && isElementEmpty && canRemoveElement(data.tag, data.attrs)) {
// remove last "element" from buffer
- insertionIndex -= removeStartTag(insertionIndex);
+ removeStartTag();
optionalStartTag = '';
optionalEndTag = '';
}
@@ -1286,7 +1242,7 @@ function minify(value, options, partialMarkup, cb) {
optionalEndTag = '';
}
else {
- buffer.splice(insertionIndex, 0, '' + data.tag + '>');
+ buffer.push('' + data.tag + '>');
}
charsPrevTag = '/' + data.tag;
if (!inlineTags(data.tag)) {
@@ -1306,18 +1262,8 @@ function minify(value, options, partialMarkup, cb) {
);
},
chars: function(text, prevTag, nextTag) {
- var placeholder = new Placeholder(); // Some unique reference.
- buffer.push(placeholder);
-
asyncTasks.push(
new AsyncTask(function(data, cb) {
- // The index of the placeholder may not be the same as where it
- // was originally inserted at; therefore we need to search for it.
- var insertionIndex = buffer.indexOf(placeholder);
-
- // Remove the placeholder.
- buffer.splice(insertionIndex, 1);
-
var subtasks = [];
data.prevTag = data.prevTag === '' ? 'comment' : data.prevTag;
data.nextTag = data.nextTag === '' ? 'comment' : data.nextTag;
@@ -1327,13 +1273,13 @@ function minify(value, options, partialMarkup, cb) {
if (options.collapseWhitespace) {
if (!stackNoTrimWhitespace.length) {
if (data.prevTag === 'comment') {
- var prevComment = buffer[insertionIndex - 1];
+ var prevComment = buffer[buffer.length - 1];
if (prevComment.indexOf(uidIgnore) === -1) {
if (!prevComment) {
data.prevTag = charsPrevTag;
}
- if (insertionIndex > 1 && (!prevComment || !options.conservativeCollapse && / $/.test(currentChars))) {
- var charsIndex = insertionIndex - 2;
+ if (buffer.length > 1 && (!prevComment || !options.conservativeCollapse && / $/.test(currentChars))) {
+ var charsIndex = buffer.length - 2;
buffer[charsIndex] = buffer[charsIndex].replace(/\s+$/, function(trailingSpaces) {
data.text = trailingSpaces + data.text;
return '';
@@ -1344,7 +1290,7 @@ function minify(value, options, partialMarkup, cb) {
if (data.prevTag) {
if (data.prevTag === '/nobr' || data.prevTag === 'wbr') {
if (/^\s/.test(data.text)) {
- var tagIndex = insertionIndex - 1;
+ var tagIndex = buffer.length - 1;
while (tagIndex > 0 && buffer[tagIndex].lastIndexOf('<' + data.prevTag) !== 0) {
tagIndex--;
}
@@ -1362,7 +1308,7 @@ function minify(value, options, partialMarkup, cb) {
data.text = collapseWhitespace(data.text, options, true, true);
}
if (!data.text && /\s$/.test(currentChars) && data.prevTag && data.prevTag.charAt(0) === '/') {
- trimTrailingWhitespace(insertionIndex - 1, data.nextTag);
+ trimTrailingWhitespace(buffer.length - 1, data.nextTag);
}
}
if (!stackNoCollapseWhitespace.length && data.nextTag !== 'html' && !(data.prevTag && data.nextTag)) {
@@ -1417,13 +1363,13 @@ function minify(value, options, partialMarkup, cb) {
// may be omitted if first thing inside is not comment
// may be omitted if first thing inside is not space, comment, , , ';
+ input = styleInput + scriptInput;
+
+ var styleOutput = '';
+ var scriptOutput = '';
+
+ test_minify_async(assert, input, {}, input);
+
+ output = styleOutput + scriptInput;
+ test_minify_async(assert, input, { minifyCSS: cssAsync }, output);
+ test_minify_async(assert, input, { minifyCSS: cssAsync, minifyJS: false }, output);
+
+ output = styleInput + scriptOutput;
+ test_minify_async(assert, input, { minifyJS: jsAsync }, output);
+ test_minify_async(assert, input, { minifyCSS: false, minifyJS: jsAsync }, output);
+
+ output = styleOutput + scriptOutput;
+ test_minify_async(assert, input, { minifyCSS: cssAsync, minifyJS: jsAsync }, output);
+ test_minify_async(assert, input, { minifyCSS: cssAsync, minifyJS: jsSync }, output);
+ test_minify_async(assert, input, { minifyCSS: cssSync, minifyJS: jsAsync }, output);
+});
+
+QUnit.test('minify error with callback', function(assert) {
+ var input = '<$unicorn>';
+
+ test_minify_async_error(assert, input, {}, 'Invalid tag name');
+});
+
+QUnit.test('error in callback', function(assert) {
+ var input = '';
+ var error = new Error();
+
+ function css() {
+ throw error;
+ }
+
+ test_minify_async_error(assert, input, { minifyCSS: css }, error);
+});
From 58ca98ec47a71e84d02c1a12fc1852771f920af6 Mon Sep 17 00:00:00 2001
From: Rebecca Stevens
Date: Fri, 20 Apr 2018 18:35:20 +1200
Subject: [PATCH 43/66] Fixed up tests.
---
tests/minifier.js | 137 ++++++++++++++++++++++------------------------
1 file changed, 66 insertions(+), 71 deletions(-)
diff --git a/tests/minifier.js b/tests/minifier.js
index 54b981ab..c5b13087 100644
--- a/tests/minifier.js
+++ b/tests/minifier.js
@@ -6,6 +6,33 @@ if (typeof minify === 'undefined') {
self.minify = require('html-minifier').minify;
}
+QUnit.test('`minifiy` exists', function(assert) {
+ assert.ok(minify);
+});
+
+/**
+ * Converts the options in the given object to use sync callbacks where possible.
+ *
+ * @param {Object} options
+ */
+function convertOptionsSyncCallbacks(options) {
+ if (options) {
+ if (typeof options.minifyJS === 'function') {
+ var minifyJS = options.minifyJS;
+ options.minifyJS = function(text, inline, callback) {
+ callback(minifyJS(text, inline));
+ };
+ }
+ if (typeof options.minifyCSS === 'function') {
+ var minifyCSS = options.minifyCSS;
+ options.minifyCSS = function(text, type, callback) {
+ callback(minifyCSS(text, type));
+ };
+ }
+ }
+ return options;
+}
+
/**
* Test the minify function synchronously, both with a callback and without.
*
@@ -33,40 +60,15 @@ function test_minify_sync(assert, input, options, output, description) {
// Standard test.
assert.equal(minify(input, options), output, descriptionPrefix + description);
- // Callback setup.
- if (options) {
- // Convert `minifyJS` to use a callback.
- if (typeof options.minifyJS === 'function') {
- var minifyJS = options.minifyJS;
- options.minifyJS = function(text, inline, callback) {
- callback(minifyJS(text, inline));
- };
- }
- // Convert `minifyCSS` to use a callback.
- if (typeof options.minifyCSS === 'function') {
- var minifyCSS = options.minifyCSS;
- options.minifyCSS = function(text, type, callback) {
- callback(minifyCSS(text, type));
- };
- }
- }
-
descriptionPrefix = 'Synchronous Callback Test: ';
var done = assert.async();
var callbackTestFinished = false;
// Callback test.
- assert.notOk(minify(input, options, function(error, result) {
+ assert.notOk(minify(input, convertOptionsSyncCallbacks(options), function(error, result) {
if (!callbackTestFinished) {
- // Error should be null
- if (error !== null) {
- if (error instanceof Error) {
- assert.equal(error, null, descriptionPrefix + 'An error occurred - stack trace:\n' + error.stack);
- }
- else {
- assert.ok(false, descriptionPrefix + '"' + error + '" was returned as an error.');
- }
- }
+ assert.notOk(error, descriptionPrefix + 'An error occurred - stack trace:\n' + error.stack);
+
assert.equal(result, output, descriptionPrefix + description);
callbackTestFinished = true;
done();
@@ -86,11 +88,17 @@ function test_minify_sync(assert, input, options, output, description) {
*
* @param {QUnit.assert} assert
* @param {string} input
- * @param {Object} options
+ * @param {Object} [options]
* @param {Error|Class|RegExp|Function} [errorMatcher]
* @param {string} [description]
*/
function test_minify_sync_error(assert, input, options, errorMatcher, description) {
+ // Remove optional options parameter if it is not given.
+ if (typeof options === 'string') {
+ description = errorMatcher;
+ errorMatcher = options;
+ options = null;
+ }
// Remove optional errorMatcher parameter if it is not given.
if (typeof errorMatcher === 'string') {
description = errorMatcher;
@@ -105,24 +113,24 @@ function test_minify_sync_error(assert, input, options, errorMatcher, descriptio
var descriptionPrefix = 'Synchronous Standard Test: ';
// Standard test.
- assert.throws(function() { minify(input, options); }, errorMatcher, descriptionPrefix + description);
+ assert.throws(
+ function() {
+ minify(input, options);
+ },
+ errorMatcher,
+ descriptionPrefix + description
+ );
descriptionPrefix = 'Synchronous Callback Test: ';
var done = assert.async();
var callbackTestFinished = false;
// Callback test.
- assert.notOk(minify(input, options, function(error, result) {
+ assert.notOk(minify(input, convertOptionsSyncCallbacks(options), function(error, result) {
if (!callbackTestFinished) {
- if (error === null) {
- assert.ok(false, descriptionPrefix + 'An error should have occurred.');
- }
- else if (error instanceof Error) {
- assert.throws(function() { throw error; }, errorMatcher, descriptionPrefix + description);
- }
- else {
- assert.ok(false, descriptionPrefix + '"' + error + '" was returned as an error.');
- }
+ assert.ok(error, descriptionPrefix + 'An error should have occurred.');
+ assert.ok(error instanceof Error, descriptionPrefix + '"' + error + '" was returned as an error.');
+ assert.throws(function() { throw error; }, errorMatcher, descriptionPrefix + description);
assert.notOk(result);
callbackTestFinished = true;
done();
@@ -159,7 +167,7 @@ function test_minify_async(assert, input, options, output, description) {
description = input;
}
- assert.timeout(100);
+ assert.timeout(10);
var descriptionPrefix = 'Asynchronous Test: ';
var done = assert.async();
@@ -199,7 +207,7 @@ function test_minify_async_error(assert, input, options, errorMatcher, descripti
description = input;
}
- assert.timeout(100);
+ assert.timeout(10);
var descriptionPrefix = 'Asynchronous Test: ';
var done = assert.async();
@@ -218,10 +226,6 @@ function test_minify_async_error(assert, input, options, errorMatcher, descripti
}));
}
-QUnit.test('`minifiy` exists', function(assert) {
- assert.ok(minify);
-});
-
QUnit.test('parsing non-trivial markup', function(assert) {
var input, output;
@@ -273,7 +277,7 @@ QUnit.test('parsing non-trivial markup', function(assert) {
test_minify_sync(assert, input, input);
input = '<$unicorn>';
- test_minify_sync_error(assert, input, {}, 'Invalid tag name');
+ test_minify_sync_error(assert, input, 'Invalid tag name');
input = '';
test_minify_sync(assert, input, input);
@@ -303,12 +307,7 @@ QUnit.test('parsing non-trivial markup', function(assert) {
// https://github.com/kangax/html-minifier/issues/507
input = '';
test_minify_sync(assert, input, input);
- test_minify_sync_error(
- assert,
- '',
- {},
- 'invalid attribute name'
- );
+ test_minify_sync_error(assert, '', 'invalid attribute name');
// https://github.com/kangax/html-minifier/issues/512
input = '';
test_minify_sync(assert, input, input);
- test_minify_sync_error(
- assert,
- '' +
- ' placeholder="YYYY-MM-DD"' +
- ' date-range-picker' +
- ' data-ng-model="vm.value"' +
- ' data-ng-model-options="{ debounce: 1000 }"' +
- ' data-ng-pattern="vm.options.format"' +
- ' data-options="vm.datepickerOptions">',
- {},
- 'HTML comment inside tag'
- );
+ input = '' +
+ ' placeholder="YYYY-MM-DD"' +
+ ' date-range-picker' +
+ ' data-ng-model="vm.value"' +
+ ' data-ng-model-options="{ debounce: 1000 }"' +
+ ' data-ng-pattern="vm.options.format"' +
+ ' data-options="vm.datepickerOptions">';
+ test_minify_sync_error(assert, input, 'HTML comment inside tag');
input = '
';
output = '
';
@@ -3071,14 +3066,14 @@ QUnit.test('custom attribute collapse', function(assert) {
input = 'foo
';
- output = 'foo
';
+ output = 'foo
';
test_minify_sync(assert, input, input);
test_minify_sync(assert, input, { customAttrCollapse: /data-bind/ }, output);
@@ -3636,13 +3631,13 @@ QUnit.test('Async execution', function(assert) {
function cssAsync(text, type, cb) {
setTimeout(function() {
cb(cssSync(text, type));
- }, 0);
+ }, 1);
}
function jsAsync(text, inline, cb) {
setTimeout(function() {
cb(jsSync(text, inline));
- }, 0);
+ }, 1);
}
var styleInput = '';
@@ -3671,7 +3666,7 @@ QUnit.test('Async execution', function(assert) {
QUnit.test('minify error with callback', function(assert) {
var input = '<$unicorn>';
- test_minify_async_error(assert, input, {}, 'Invalid tag name');
+ test_minify_async_error(assert, input, 'Invalid tag name');
});
QUnit.test('error in callback', function(assert) {
From 8e4351d7eb450b6fa2f8e8fcdc5d25b78e4e4a22 Mon Sep 17 00:00:00 2001
From: Rebecca Stevens
Date: Fri, 20 Apr 2018 18:36:03 +1200
Subject: [PATCH 44/66] Added 'callback called multiple times' tests.
---
tests/minifier.js | 27 +++++++++++++++++++++++++++
1 file changed, 27 insertions(+)
diff --git a/tests/minifier.js b/tests/minifier.js
index c5b13087..a3982aa3 100644
--- a/tests/minifier.js
+++ b/tests/minifier.js
@@ -3679,3 +3679,30 @@ QUnit.test('error in callback', function(assert) {
test_minify_async_error(assert, input, { minifyCSS: css }, error);
});
+
+QUnit.test('callback called multiple times', function(assert) {
+ var input, done;
+
+ function bad(cb) {
+ try {
+ cb('');
+ cb('');
+ assert.ok(false, 'An error should be thrown.');
+ }
+ catch (error) {
+ assert.equal(error.message, 'Async completion has already occurred.');
+ }
+ finally {
+ done();
+ }
+ }
+
+ done = assert.async();
+ test_minify_async_error(assert, input, { minifyCSS: bad });
+
+ done = assert.async();
+ test_minify_async_error(assert, input, { minifyJS: bad });
+
+ done = assert.async();
+ test_minify_async_error(assert, input, { minifyCSS: bad, minifyJS: bad });
+});
From 5961a660e584fb7038cfe2dcfe132099a6eeb223 Mon Sep 17 00:00:00 2001
From: Rebecca Stevens
Date: Mon, 23 Apr 2018 16:37:28 +1200
Subject: [PATCH 45/66] Fixed bad test 'callback called multiple times' and got
it passing.
---
src/htmlminifier.js | 10 ++++++++--
tests/minifier.js | 12 +++++++-----
2 files changed, 15 insertions(+), 7 deletions(-)
diff --git a/src/htmlminifier.js b/src/htmlminifier.js
index 56c5a321..2a5fcee6 100644
--- a/src/htmlminifier.js
+++ b/src/htmlminifier.js
@@ -1320,7 +1320,10 @@ function minify(value, options, partialMarkup, cb) {
var callbackCalled = false;
function minifyJS_cb(result) {
- if (!callbackCalled) {
+ if (callbackCalled) {
+ throw new Error('Async completion has already occurred.');
+ }
+ else {
callbackCalled = true;
text = result;
return cb();
@@ -1337,7 +1340,10 @@ function minify(value, options, partialMarkup, cb) {
var callbackCalled = false;
function minifyCSS_cb(result) {
- if (!callbackCalled) {
+ if (callbackCalled) {
+ throw new Error('Async completion has already occurred.');
+ }
+ else {
callbackCalled = true;
text = result;
return cb();
diff --git a/tests/minifier.js b/tests/minifier.js
index a3982aa3..2288da00 100644
--- a/tests/minifier.js
+++ b/tests/minifier.js
@@ -3683,7 +3683,7 @@ QUnit.test('error in callback', function(assert) {
QUnit.test('callback called multiple times', function(assert) {
var input, done;
- function bad(cb) {
+ function bad(_, __, cb) {
try {
cb('');
cb('');
@@ -3697,12 +3697,14 @@ QUnit.test('callback called multiple times', function(assert) {
}
}
- done = assert.async();
- test_minify_async_error(assert, input, { minifyCSS: bad });
+ input = '';
done = assert.async();
- test_minify_async_error(assert, input, { minifyJS: bad });
+ minify(input, { minifyCSS: bad });
done = assert.async();
- test_minify_async_error(assert, input, { minifyCSS: bad, minifyJS: bad });
+ minify(input, { minifyJS: bad });
+
+ done = assert.async(2);
+ minify(input, { minifyCSS: bad, minifyJS: bad });
});
From adad66503ecd2f97327a9f80bd9d5d470ad6dd96 Mon Sep 17 00:00:00 2001
From: Rebecca Stevens
Date: Mon, 23 Apr 2018 17:20:23 +1200
Subject: [PATCH 46/66] Fixed bug in tests causing them to throw errors.
---
tests/minifier.js | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/tests/minifier.js b/tests/minifier.js
index 2288da00..32765534 100644
--- a/tests/minifier.js
+++ b/tests/minifier.js
@@ -67,9 +67,14 @@ function test_minify_sync(assert, input, options, output, description) {
// Callback test.
assert.notOk(minify(input, convertOptionsSyncCallbacks(options), function(error, result) {
if (!callbackTestFinished) {
- assert.notOk(error, descriptionPrefix + 'An error occurred - stack trace:\n' + error.stack);
+ var stackTrace = '';
+ if (error && error instanceof Error) {
+ stackTrace = error.stack;
+ }
+ assert.notOk(error, descriptionPrefix + 'An error occurred - stack trace:\n' + stackTrace);
assert.equal(result, output, descriptionPrefix + description);
+
callbackTestFinished = true;
done();
}
From f57abf3af7e4c783128cdf3e26697776814929c4 Mon Sep 17 00:00:00 2001
From: Rebecca Stevens
Date: Mon, 23 Apr 2018 17:26:03 +1200
Subject: [PATCH 47/66] Fixed up tests.
---
tests/minifier.js | 28 ++++++++++------------------
1 file changed, 10 insertions(+), 18 deletions(-)
diff --git a/tests/minifier.js b/tests/minifier.js
index 32765534..b2bf4f85 100644
--- a/tests/minifier.js
+++ b/tests/minifier.js
@@ -72,7 +72,7 @@ function test_minify_sync(assert, input, options, output, description) {
stackTrace = error.stack;
}
- assert.notOk(error, descriptionPrefix + 'An error occurred - stack trace:\n' + stackTrace);
+ assert.equal(error, null, descriptionPrefix + 'An error occurred - stack trace:\n' + stackTrace);
assert.equal(result, output, descriptionPrefix + description);
callbackTestFinished = true;
@@ -177,16 +177,14 @@ function test_minify_async(assert, input, options, output, description) {
var done = assert.async();
assert.notOk(minify(input, options, function(error, result) {
- // Error should be null
- if (error !== null) {
- if (error instanceof Error) {
- assert.equal(error, null, descriptionPrefix + 'An error occurred - stack trace:\n' + error.stack);
- }
- else {
- assert.ok(false, descriptionPrefix + '"' + error + '" was returned as an error.');
- }
+ var stackTrace = '';
+ if (error && error instanceof Error) {
+ stackTrace = error.stack;
}
+
+ assert.equal(error, null, descriptionPrefix + 'An error occurred - stack trace:\n' + stackTrace);
assert.equal(result, output, descriptionPrefix + description);
+
done();
}));
}
@@ -217,15 +215,9 @@ function test_minify_async_error(assert, input, options, errorMatcher, descripti
var done = assert.async();
assert.notOk(minify(input, options, function(error, result) {
- if (error === null) {
- assert.ok(false, descriptionPrefix + 'An error should have occurred.');
- }
- else if (error instanceof Error) {
- assert.throws(function() { throw error; }, errorMatcher, descriptionPrefix + description);
- }
- else {
- assert.ok(false, descriptionPrefix + '"' + error + '" was returned as an error.');
- }
+ assert.ok(error, descriptionPrefix + 'An error should have occurred.');
+ assert.ok(error instanceof Error, descriptionPrefix + '"' + error + '" was returned as an error.');
+ assert.throws(function() { throw error; }, errorMatcher, descriptionPrefix + description);
assert.notOk(result);
done();
}));
From 587da3848ceaf002b63e968dc55620d9eb310eae Mon Sep 17 00:00:00 2001
From: Rebecca Stevens
Date: Mon, 23 Apr 2018 17:27:44 +1200
Subject: [PATCH 48/66] Fixed up jsdoc.
---
src/htmlminifier.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/htmlminifier.js b/src/htmlminifier.js
index 2a5fcee6..5afa1230 100644
--- a/src/htmlminifier.js
+++ b/src/htmlminifier.js
@@ -877,7 +877,7 @@ function minify(value, options, partialMarkup, cb) {
*
* @constructor
*
- * @param {Function>} task
+ * @param {Function>} task
*/
function Task(task) {
this.task = task;
From 9addaf62bab54b8960e0bdad74676f940f95cfbf Mon Sep 17 00:00:00 2001
From: Rebecca Stevens
Date: Mon, 23 Apr 2018 17:34:17 +1200
Subject: [PATCH 49/66] Increased timout.
---
tests/minifier.js | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/tests/minifier.js b/tests/minifier.js
index b2bf4f85..18113010 100644
--- a/tests/minifier.js
+++ b/tests/minifier.js
@@ -172,7 +172,7 @@ function test_minify_async(assert, input, options, output, description) {
description = input;
}
- assert.timeout(10);
+ assert.timeout(100);
var descriptionPrefix = 'Asynchronous Test: ';
var done = assert.async();
@@ -210,7 +210,7 @@ function test_minify_async_error(assert, input, options, errorMatcher, descripti
description = input;
}
- assert.timeout(10);
+ assert.timeout(100);
var descriptionPrefix = 'Asynchronous Test: ';
var done = assert.async();
From 99d8546500dcefe275efa762ba45afb0d0c22420 Mon Sep 17 00:00:00 2001
From: Rebecca Stevens
Date: Mon, 23 Apr 2018 22:15:48 +1200
Subject: [PATCH 50/66] Made the test_minify_async_error consistent with
test_minify_sync_error
---
tests/minifier.js | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/tests/minifier.js b/tests/minifier.js
index 18113010..6f7634be 100644
--- a/tests/minifier.js
+++ b/tests/minifier.js
@@ -104,6 +104,7 @@ function test_minify_sync_error(assert, input, options, errorMatcher, descriptio
errorMatcher = options;
options = null;
}
+
// Remove optional errorMatcher parameter if it is not given.
if (typeof errorMatcher === 'string') {
description = errorMatcher;
@@ -194,11 +195,18 @@ function test_minify_async(assert, input, options, output, description) {
*
* @param {QUnit.assert} assert
* @param {string} input
- * @param {Object} options
+ * @param {Object} [options]
* @param {Error|Class|RegExp|Function} [errorMatcher]
* @param {string} [description]
*/
function test_minify_async_error(assert, input, options, errorMatcher, description) {
+ // Remove optional options parameter if it is not given.
+ if (typeof options === 'string') {
+ description = errorMatcher;
+ errorMatcher = options;
+ options = null;
+ }
+
// Remove optional errorMatcher parameter if it is not given.
if (typeof errorMatcher === 'string') {
description = errorMatcher;
From 3552c4e3e2ed3e95b6107406c7ac1bbd34a63bc3 Mon Sep 17 00:00:00 2001
From: Rebecca Stevens
Date: Mon, 23 Apr 2018 23:10:33 +1200
Subject: [PATCH 51/66] Fixed up jsdoc types.
---
src/htmlminifier.js | 13 +++++++++----
tests/minifier.js | 12 ++++++------
2 files changed, 15 insertions(+), 10 deletions(-)
diff --git a/src/htmlminifier.js b/src/htmlminifier.js
index 5afa1230..42ab0ae0 100644
--- a/src/htmlminifier.js
+++ b/src/htmlminifier.js
@@ -1,5 +1,10 @@
'use strict';
+/**
+ * A callback that tasks an error and a result.
+ * @typedef {function([?Error], [string]):void} Callback
+ */
+
var CleanCSS = require('clean-css');
var decode = require('he').decode;
var HTMLParser = require('./htmlparser').HTMLParser;
@@ -842,7 +847,7 @@ function createSortFns(value, options, uidIgnore, uidAttr, cb) {
* @param {string} value
* @param {Object} options
* @param {boolean} partialMarkup
- * @param {Function} cb
+ * @param {Callback} cb
*/
function minify(value, options, partialMarkup, cb) {
if (options.collapseWhitespace) {
@@ -877,7 +882,7 @@ function minify(value, options, partialMarkup, cb) {
*
* @constructor
*
- * @param {Function>} task
+ * @param {function(Callback)} task
*/
function Task(task) {
this.task = task;
@@ -886,7 +891,7 @@ function minify(value, options, partialMarkup, cb) {
/**
* Execute this task.
*
- * @param {Function} cb
+ * @param {Callback} cb
*/
Task.prototype.exec = function(cb) {
this.task(cb);
@@ -906,7 +911,7 @@ function minify(value, options, partialMarkup, cb) {
/**
* Run all tasks in this group in series.
*
- * @param {Function} cb
+ * @param {Callback} cb
*/
TaskGroup.prototype.exec = function(cb) {
/**
diff --git a/tests/minifier.js b/tests/minifier.js
index 6f7634be..bbe26ba6 100644
--- a/tests/minifier.js
+++ b/tests/minifier.js
@@ -36,7 +36,7 @@ function convertOptionsSyncCallbacks(options) {
/**
* Test the minify function synchronously, both with a callback and without.
*
- * @param {QUnit.assert} assert
+ * @param {Assert} assert
* @param {string} input
* @param {Object} [options]
* @param {string} output
@@ -91,10 +91,10 @@ function test_minify_sync(assert, input, options, output, description) {
/**
* Test the minify function synchronously for an expected error, both with a callback and without.
*
- * @param {QUnit.assert} assert
+ * @param {Assert} assert
* @param {string} input
* @param {Object} [options]
- * @param {Error|Class|RegExp|Function} [errorMatcher]
+ * @param {Error|function(new:Error)|RegExp|function(boolean)} [errorMatcher]
* @param {string} [description]
*/
function test_minify_sync_error(assert, input, options, errorMatcher, description) {
@@ -154,7 +154,7 @@ function test_minify_sync_error(assert, input, options, errorMatcher, descriptio
/**
* Test the minify function asynchronously.
*
- * @param {QUnit.assert} assert
+ * @param {Assert} assert
* @param {string} input
* @param {Object} [options]
* @param {string} output
@@ -193,10 +193,10 @@ function test_minify_async(assert, input, options, output, description) {
/**
* Test the minify function asynchronously for an expected error.
*
- * @param {QUnit.assert} assert
+ * @param {Assert} assert
* @param {string} input
* @param {Object} [options]
- * @param {Error|Class|RegExp|Function} [errorMatcher]
+ * @param {Error|function(new:Error)|RegExp|function(boolean)} [errorMatcher]
* @param {string} [description]
*/
function test_minify_async_error(assert, input, options, errorMatcher, description) {
From 31edf01dbb1bc19a711861eafa253923d3e39a9e Mon Sep 17 00:00:00 2001
From: Rebecca Stevens
Date: Tue, 24 Apr 2018 16:53:02 +1200
Subject: [PATCH 52/66] Merged async and sync test functions togetehr.
---
tests/minifier.js | 2353 ++++++++++++++++++++++-----------------------
1 file changed, 1174 insertions(+), 1179 deletions(-)
diff --git a/tests/minifier.js b/tests/minifier.js
index bbe26ba6..dcdad2d2 100644
--- a/tests/minifier.js
+++ b/tests/minifier.js
@@ -1,318 +1,317 @@
/* global minify */
'use strict';
-QUnit.config.autostart = false;
-if (typeof minify === 'undefined') {
- self.minify = require('html-minifier').minify;
-}
-
-QUnit.test('`minifiy` exists', function(assert) {
- assert.ok(minify);
-});
-
/**
- * Converts the options in the given object to use sync callbacks where possible.
+ * Converts the options in the given object to use callbacks where possible.
*
- * @param {Object} options
+ * @param {?Object} options
+ * @param {boolean} [async=false]
+ * @returns {Object}
*/
-function convertOptionsSyncCallbacks(options) {
+function convertOptionsCallbacks(options, async) {
+ var convertedOptions = {};
+
if (options) {
+ for (var i in options) {
+ convertedOptions[i] = options[i];
+ }
+
if (typeof options.minifyJS === 'function') {
- var minifyJS = options.minifyJS;
- options.minifyJS = function(text, inline, callback) {
- callback(minifyJS(text, inline));
+ convertedOptions.minifyJS = function(text, inline, cb) {
+ function runMinifyJS() {
+ var result = options.minifyJS(text, inline, cb);
+ if (typeof result !== 'undefined') {
+ cb(result);
+ }
+ }
+
+ if (async) {
+ setTimeout(function() {
+ runMinifyJS();
+ }, 1);
+ }
+ else {
+ runMinifyJS();
+ }
};
}
if (typeof options.minifyCSS === 'function') {
- var minifyCSS = options.minifyCSS;
- options.minifyCSS = function(text, type, callback) {
- callback(minifyCSS(text, type));
+ convertedOptions.minifyCSS = function(text, type, cb) {
+ function runMinifyCSS() {
+ var result = options.minifyCSS(text, type, cb);
+ if (typeof result !== 'undefined') {
+ cb(result);
+ }
+ }
+
+ if (async) {
+ setTimeout(function() {
+ runMinifyCSS();
+ }, 1);
+ }
+ else {
+ runMinifyCSS();
+ }
};
}
}
- return options;
+
+ return convertedOptions;
}
/**
- * Test the minify function synchronously, both with a callback and without.
+ * Test the minify function.
*
* @param {Assert} assert
* @param {string} input
- * @param {Object} [options]
* @param {string} output
- * @param {string} [description]
+ * @param {Object} [inputOptions]
+ * @param {string} [description=input]
+ * @param {boolean} [asyncOnly=false]
*/
-function test_minify_sync(assert, input, options, output, description) {
- // Remove optional options parameter if it is not given.
- if (typeof options === 'string') {
- description = output;
- output = options;
- options = null;
- }
-
- // Set default description as input.
- if (typeof description === 'undefined') {
+function test_minify(assert, input, output, inputOptions, description, asyncOnly) {
+ // Set default description.
+ if (description === null || typeof description === 'undefined') {
description = input;
}
- var descriptionPrefix = 'Synchronous Standard Test: ';
+ // Set default asyncOnly.
+ if (asyncOnly === null || typeof asyncOnly === 'undefined') {
+ asyncOnly = false;
+ }
// Standard test.
- assert.equal(minify(input, options), output, descriptionPrefix + description);
+ if (!asyncOnly) {
+ var descriptionPrefix = 'Standard Test: ';
+ assert.equal(minify(input, inputOptions), output, descriptionPrefix + description);
+ }
- descriptionPrefix = 'Synchronous Callback Test: ';
- var done = assert.async();
- var callbackTestFinished = false;
+ // Callback tests.
+ var callbackTests = [];
+
+ if (!asyncOnly) {
+ // Sync callback test.
+ callbackTests.push({
+ options: convertOptionsCallbacks(inputOptions, false),
+ async: false,
+ done: assert.async(),
+ descriptionPrefix: 'Synchronous Callback Test: '
+ });
+ }
- // Callback test.
- assert.notOk(minify(input, convertOptionsSyncCallbacks(options), function(error, result) {
- if (!callbackTestFinished) {
- var stackTrace = '';
- if (error && error instanceof Error) {
- stackTrace = error.stack;
- }
+ // Async callback test.
+ callbackTests.push({
+ options: asyncOnly ? inputOptions : convertOptionsCallbacks(inputOptions, true),
+ async: true,
+ done: assert.async(),
+ descriptionPrefix: 'Asynchronous Callback Test: '
+ });
- assert.equal(error, null, descriptionPrefix + 'An error occurred - stack trace:\n' + stackTrace);
- assert.equal(result, output, descriptionPrefix + description);
+ // Run callback tests.
+ assert.timeout(100);
+ callbackTests.forEach(function(test) {
+ var callbackTestFinished = false;
+ assert.notOk(minify(input, test.options, function(error, result) {
+ if (!callbackTestFinished) {
+ var stackTrace = '';
+ if (error && error instanceof Error) {
+ stackTrace = error.stack;
+ }
+
+ assert.equal(error, null, test.descriptionPrefix + 'An error occurred - stack trace:\n' + stackTrace);
+ assert.equal(result, output, test.descriptionPrefix + description);
+
+ callbackTestFinished = true;
+ test.done();
+ }
+ }));
+ // If callback test didn't finish synchronously.
+ if (!callbackTestFinished && !test.async) {
+ assert.ok(false, test.descriptionPrefix + 'Didn\'t finish synchronously.');
callbackTestFinished = true;
- done();
+ test.done();
}
- }));
-
- // If callback test didn't finish synchronously.
- if (!callbackTestFinished) {
- assert.ok(false, descriptionPrefix + 'Didn\'t finish synchronously.');
- callbackTestFinished = true;
- done();
- }
+ });
}
/**
- * Test the minify function synchronously for an expected error, both with a callback and without.
+ * Test the minify function for an expected error.
*
* @param {Assert} assert
* @param {string} input
* @param {Object} [options]
* @param {Error|function(new:Error)|RegExp|function(boolean)} [errorMatcher]
- * @param {string} [description]
+ * @param {string} [description=input]
+ * @param {boolean} [asyncOnly=false]
*/
-function test_minify_sync_error(assert, input, options, errorMatcher, description) {
- // Remove optional options parameter if it is not given.
- if (typeof options === 'string') {
- description = errorMatcher;
- errorMatcher = options;
- options = null;
- }
-
- // Remove optional errorMatcher parameter if it is not given.
- if (typeof errorMatcher === 'string') {
- description = errorMatcher;
- errorMatcher = null;
- }
-
- // Set default description as input.
- if (typeof description === 'undefined') {
+function test_minify_error(assert, input, inputOptions, errorMatcher, description, asyncOnly) {
+ // Set default description.
+ if (description === null || typeof description === 'undefined') {
description = input;
}
- var descriptionPrefix = 'Synchronous Standard Test: ';
+ // Set default asyncOnly.
+ if (asyncOnly === null || typeof asyncOnly === 'undefined') {
+ asyncOnly = false;
+ }
// Standard test.
+ var descriptionPrefix = 'Standard Test: ';
assert.throws(
function() {
- minify(input, options);
+ minify(input, inputOptions);
},
errorMatcher,
descriptionPrefix + description
);
- descriptionPrefix = 'Synchronous Callback Test: ';
- var done = assert.async();
- var callbackTestFinished = false;
-
- // Callback test.
- assert.notOk(minify(input, convertOptionsSyncCallbacks(options), function(error, result) {
- if (!callbackTestFinished) {
- assert.ok(error, descriptionPrefix + 'An error should have occurred.');
- assert.ok(error instanceof Error, descriptionPrefix + '"' + error + '" was returned as an error.');
- assert.throws(function() { throw error; }, errorMatcher, descriptionPrefix + description);
- assert.notOk(result);
- callbackTestFinished = true;
- done();
- }
- }));
-
- // If callback test didn't finish synchronously.
- if (!callbackTestFinished) {
- assert.ok(false, descriptionPrefix + 'Didn\'t finish synchronously.');
- callbackTestFinished = true;
- done();
- }
-}
-
-/**
- * Test the minify function asynchronously.
- *
- * @param {Assert} assert
- * @param {string} input
- * @param {Object} [options]
- * @param {string} output
- * @param {string} [description]
- */
-function test_minify_async(assert, input, options, output, description) {
- // Remove optional options parameter if it is not given.
- if (typeof options === 'string') {
- description = output;
- output = options;
- options = null;
+ // Callback tests.
+ var callbackTests = [];
+
+ if (!asyncOnly) {
+ // Sync callback test.
+ callbackTests.push({
+ options: convertOptionsCallbacks(inputOptions, false),
+ async: false,
+ done: assert.async(),
+ descriptionPrefix: 'Synchronous Callback Test: '
+ });
}
- // Set default description as input.
- if (typeof description === 'undefined') {
- description = input;
- }
-
- assert.timeout(100);
- var descriptionPrefix = 'Asynchronous Test: ';
- var done = assert.async();
+ // Async callback test.
+ callbackTests.push({
+ options: asyncOnly ? inputOptions : convertOptionsCallbacks(inputOptions, true),
+ async: true,
+ done: assert.async(),
+ descriptionPrefix: 'Asynchronous Callback Test: '
+ });
- assert.notOk(minify(input, options, function(error, result) {
- var stackTrace = '';
- if (error && error instanceof Error) {
- stackTrace = error.stack;
+ // Run callback tests.
+ callbackTests.forEach(function(test) {
+ var callbackTestFinished = false;
+ try {
+ assert.timeout(100);
+ assert.notOk(minify(input, test.options, function(error, result) {
+ if (!callbackTestFinished) {
+ assert.ok(error, descriptionPrefix + 'An error should have occurred.');
+ assert.ok(error instanceof Error, descriptionPrefix + '"' + error + '" was returned as an error.');
+ assert.throws(function() { throw error; }, errorMatcher, descriptionPrefix + description);
+ assert.notOk(result);
+
+ callbackTestFinished = true;
+ test.done();
+ }
+ }));
+
+ // If callback test didn't finish synchronously.
+ if (!callbackTestFinished && !test.async) {
+ assert.ok(false, test.descriptionPrefix + 'Didn\'t finish synchronously.');
+ callbackTestFinished = true;
+ test.done();
+ }
}
-
- assert.equal(error, null, descriptionPrefix + 'An error occurred - stack trace:\n' + stackTrace);
- assert.equal(result, output, descriptionPrefix + description);
-
- done();
- }));
+ catch (error) {
+ callbackTestFinished = true;
+ if (error && error instanceof Error) {
+ assert.ok(false, test.descriptionPrefix + 'threw an error - stack trace:\n' + error.stack);
+ }
+ else {
+ assert.ok(false, test.descriptionPrefix + 'threw an error - "' + error + '"');
+ }
+ }
+ });
}
-/**
- * Test the minify function asynchronously for an expected error.
- *
- * @param {Assert} assert
- * @param {string} input
- * @param {Object} [options]
- * @param {Error|function(new:Error)|RegExp|function(boolean)} [errorMatcher]
- * @param {string} [description]
- */
-function test_minify_async_error(assert, input, options, errorMatcher, description) {
- // Remove optional options parameter if it is not given.
- if (typeof options === 'string') {
- description = errorMatcher;
- errorMatcher = options;
- options = null;
- }
-
- // Remove optional errorMatcher parameter if it is not given.
- if (typeof errorMatcher === 'string') {
- description = errorMatcher;
- errorMatcher = null;
- }
-
- // Set default description as input.
- if (typeof description === 'undefined') {
- description = input;
- }
-
- assert.timeout(100);
- var descriptionPrefix = 'Asynchronous Test: ';
- var done = assert.async();
-
- assert.notOk(minify(input, options, function(error, result) {
- assert.ok(error, descriptionPrefix + 'An error should have occurred.');
- assert.ok(error instanceof Error, descriptionPrefix + '"' + error + '" was returned as an error.');
- assert.throws(function() { throw error; }, errorMatcher, descriptionPrefix + description);
- assert.notOk(result);
- done();
- }));
+QUnit.config.autostart = false;
+if (typeof minify === 'undefined') {
+ self.minify = require('html-minifier').minify;
}
+QUnit.test('`minifiy` exists', function(assert) {
+ assert.ok(minify);
+});
+
QUnit.test('parsing non-trivial markup', function(assert) {
var input, output;
- test_minify_sync(assert, '', '');
- test_minify_sync(assert, '', '');
- test_minify_sync(assert, '', '
');
- test_minify_sync(assert, '
x', '
x
');
- test_minify_sync(assert, 'x
', 'x
');
- test_minify_sync(assert, 'x
', 'x
');
- test_minify_sync(assert, 'x
', 'x
');
- test_minify_sync(assert, 'xxx
', 'xxx
');
- test_minify_sync(assert, 'xxx
', 'xxx
');
- test_minify_sync(assert, 'xxx
', 'xxx
');
+ test_minify(assert, '', '');
+ test_minify(assert, '', '');
+ test_minify(assert, '', '
');
+ test_minify(assert, '
x', '
x
');
+ test_minify(assert, 'x
', 'x
');
+ test_minify(assert, 'x
', 'x
');
+ test_minify(assert, 'x
', 'x
');
+ test_minify(assert, 'xxx
', 'xxx
');
+ test_minify(assert, 'xxx
', 'xxx
');
+ test_minify(assert, 'xxx
', 'xxx
');
input = '' +
'i\'m 10 levels deep' +
'
';
- test_minify_sync(assert, input, input);
+ test_minify(assert, input, input);
- test_minify_sync(assert, '', '');
- test_minify_sync(assert, '', '');
- test_minify_sync(assert, '', '');
+ test_minify(assert, '', '');
+ test_minify(assert, '', '');
+ test_minify(assert, '', '');
- test_minify_sync(assert, 'foo', 'foo');
- test_minify_sync(assert, 'x', '
x
');
- test_minify_sync(assert, 'x
', 'x
', 'trailing quote should be ignored');
- test_minify_sync(assert, 'Click me
', 'Click me
');
- test_minify_sync(assert, '', '');
- test_minify_sync(assert, '',
- ''
- );
+ test_minify(assert, 'foo', 'foo');
+ test_minify(assert, 'x', '
x
');
+ test_minify(assert, 'x
', 'x
', 'trailing quote should be ignored');
+ test_minify(assert, 'Click me
', 'Click me
');
+ test_minify(assert, '', '');
+ test_minify(assert, '', '');
- test_minify_sync(assert, '', '');
- test_minify_sync(assert, '', '');
- test_minify_sync(assert, '',
- ''
- );
+ test_minify(assert, '', '');
+ test_minify(assert, '', '');
+ test_minify(assert, '', '');
// will cause test to time-out if fail
input = 'For more information, read this Stack Overflow answer.
';
output = 'For more information, read this Stack Overflow answer.
';
- test_minify_sync(assert, input, output);
+ test_minify(assert, input, output);
input = '';
- test_minify_sync(assert, input, input);
+ test_minify(assert, input, input);
input = '';
- test_minify_sync(assert, input, input);
+ test_minify(assert, input, input);
input = '<$unicorn>';
- test_minify_sync_error(assert, input, 'Invalid tag name');
+ assert.throws(function() {
+ minify(input);
+ }, 'Invalid tag name');
input = '';
- test_minify_sync(assert, input, input);
+ test_minify(assert, input, input);
// https://github.com/kangax/html-minifier/issues/41
- test_minify_sync(assert, '',
- ''
- );
+ test_minify(assert, '', '');
// https://github.com/kangax/html-minifier/issues/40
- test_minify_sync(assert, '[\']["]', '[\']["]');
+ test_minify(assert, '[\']["]', '[\']["]');
// https://github.com/kangax/html-minifier/issues/21
- test_minify_sync(assert, 'hey
', 'hey
');
+ test_minify(assert, 'hey
', 'hey
');
// https://github.com/kangax/html-minifier/issues/17
- test_minify_sync(assert, ':) link', ':) link');
+ test_minify(assert, ':) link', ':) link');
// https://github.com/kangax/html-minifier/issues/169
- test_minify_sync(assert, 'ok', 'ok');
+ test_minify(assert, 'ok', 'ok');
- test_minify_sync(assert, '', '');
+ test_minify(assert, '', '');
// https://github.com/kangax/html-minifier/issues/229
- test_minify_sync(assert, 'Hello :)
', 'Hello :)
');
+ test_minify(assert, 'Hello :)
', 'Hello :)
');
// https://github.com/kangax/html-minifier/issues/507
input = '';
- test_minify_sync(assert, input, input);
- test_minify_sync_error(assert, '', 'invalid attribute name');
+ test_minify(assert, input, input);
+ assert.throws(function() {
+ minify('');
+ }, 'invalid attribute name');
// https://github.com/kangax/html-minifier/issues/512
input = '';
- test_minify_sync(assert, input, input);
- input = '' +
- ' placeholder="YYYY-MM-DD"' +
- ' date-range-picker' +
- ' data-ng-model="vm.value"' +
- ' data-ng-model-options="{ debounce: 1000 }"' +
- ' data-ng-pattern="vm.options.format"' +
- ' data-options="vm.datepickerOptions">';
- test_minify_sync_error(assert, input, 'HTML comment inside tag');
+ test_minify(assert, input, input);
+ assert.throws(function() {
+ minify(
+ '' +
+ ' placeholder="YYYY-MM-DD"' +
+ ' date-range-picker' +
+ ' data-ng-model="vm.value"' +
+ ' data-ng-model-options="{ debounce: 1000 }"' +
+ ' data-ng-pattern="vm.options.format"' +
+ ' data-options="vm.datepickerOptions">'
+ );
+ }, 'HTML comment inside tag');
input = '
';
output = '
';
- test_minify_sync(assert, input, output);
+ test_minify(assert, input, output);
output = '
';
- test_minify_sync(assert, input, {
+ test_minify(assert, input, output, {
decodeEntities: true,
removeTagWhitespace: true,
- }, output);
+ });
output = '
';
- test_minify_sync(assert, input, {
+ test_minify(assert, input, output, {
decodeEntities: true,
removeAttributeQuotes: true
- }, output);
- test_minify_sync(assert, input, {
+ });
+ test_minify(assert, input, output, {
decodeEntities: true,
removeAttributeQuotes: true,
removeTagWhitespace: true,
- }, output);
+ });
});
QUnit.test('options', function(assert) {
var input = 'blahblah 2blah 3
';
- test_minify_sync(assert, input, input);
- test_minify_sync(assert, input, {}, input);
+ test_minify(assert, input, input);
+ test_minify(assert, input, input, {});
});
QUnit.test('case normalization', function(assert) {
- test_minify_sync(assert, 'foo
', 'foo
');
- test_minify_sync(assert, 'boo
', 'boo
');
- test_minify_sync(assert, 'boo
', 'boo
');
- test_minify_sync(assert, 'boo
', 'boo
');
- test_minify_sync(assert, 'boo
', 'boo
');
- test_minify_sync(assert, 'boo
', 'boo
');
+ test_minify(assert, 'foo
', 'foo
');
+ test_minify(assert, 'boo
', 'boo
');
+ test_minify(assert, 'boo
', 'boo
');
+ test_minify(assert, 'boo
', 'boo
');
+ test_minify(assert, 'boo
', 'boo
');
+ test_minify(assert, 'boo
', 'boo
');
});
QUnit.test('space normalization between attributes', function(assert) {
- test_minify_sync(assert, 'foo
', 'foo
');
- test_minify_sync(assert, '
', '
');
- test_minify_sync(assert, 'foo
', 'foo
');
- test_minify_sync(assert, 'foo
', 'foo
');
- test_minify_sync(assert, '
', '
');
- test_minify_sync(assert, '', '');
+ test_minify(assert, 'foo
', 'foo
');
+ test_minify(assert, '
', '
');
+ test_minify(assert, 'foo
', 'foo
');
+ test_minify(assert, 'foo
', 'foo
');
+ test_minify(assert, '
', '
');
+ test_minify(assert, '', '');
});
QUnit.test('space normalization around text', function(assert) {
var input, output;
input = ' blah
\n\n\n ';
- test_minify_sync(assert, input, input);
+ test_minify(assert, input, input);
output = 'blah
';
- test_minify_sync(assert, input, { collapseWhitespace: true }, output);
+ test_minify(assert, input, output, { collapseWhitespace: true });
output = ' blah
';
- test_minify_sync(assert, input, {
+ test_minify(assert, input, output, {
collapseWhitespace: true,
conservativeCollapse: true
- }, output);
+ });
output = 'blah
\n';
- test_minify_sync(assert, input, {
+ test_minify(assert, input, output, {
collapseWhitespace: true,
preserveLineBreaks: true
- }, output);
+ });
output = ' blah
\n';
- test_minify_sync(assert, input, {
+ test_minify(assert, input, output, {
collapseWhitespace: true,
conservativeCollapse: true,
preserveLineBreaks: true
- }, output);
+ });
[
'a', 'abbr', 'acronym', 'b', 'big', 'del', 'em', 'font', 'i', 'ins', 'kbd',
'mark', 's', 'samp', 'small', 'span', 'strike', 'strong', 'sub', 'sup',
'time', 'tt', 'u', 'var'
].forEach(function(el) {
- test_minify_sync(assert, 'foo <' + el + '>baz' + el + '> bar', { collapseWhitespace: true }, 'foo <' + el + '>baz' + el + '> bar');
- test_minify_sync(assert, 'foo<' + el + '>baz' + el + '>bar', { collapseWhitespace: true }, 'foo<' + el + '>baz' + el + '>bar');
- test_minify_sync(assert, 'foo <' + el + '>baz' + el + '>bar', { collapseWhitespace: true }, 'foo <' + el + '>baz' + el + '>bar');
- test_minify_sync(assert, 'foo<' + el + '>baz' + el + '> bar', { collapseWhitespace: true }, 'foo<' + el + '>baz' + el + '> bar');
- test_minify_sync(assert, 'foo <' + el + '> baz ' + el + '> bar', { collapseWhitespace: true }, 'foo <' + el + '>baz ' + el + '>bar');
- test_minify_sync(assert, 'foo<' + el + '> baz ' + el + '>bar', { collapseWhitespace: true }, 'foo<' + el + '> baz ' + el + '>bar');
- test_minify_sync(assert, 'foo <' + el + '> baz ' + el + '>bar', { collapseWhitespace: true }, 'foo <' + el + '>baz ' + el + '>bar');
- test_minify_sync(assert, 'foo<' + el + '> baz ' + el + '> bar', { collapseWhitespace: true }, 'foo<' + el + '> baz ' + el + '>bar');
- test_minify_sync(assert, 'foo <' + el + '>baz' + el + '> bar
', { collapseWhitespace: true }, 'foo <' + el + '>baz' + el + '> bar
');
- test_minify_sync(assert, 'foo<' + el + '>baz' + el + '>bar
', { collapseWhitespace: true }, 'foo<' + el + '>baz' + el + '>bar
');
- test_minify_sync(assert, 'foo <' + el + '>baz' + el + '>bar
', { collapseWhitespace: true }, 'foo <' + el + '>baz' + el + '>bar
');
- test_minify_sync(assert, 'foo<' + el + '>baz' + el + '> bar
', { collapseWhitespace: true }, 'foo<' + el + '>baz' + el + '> bar
');
- test_minify_sync(assert, 'foo <' + el + '> baz ' + el + '> bar
', { collapseWhitespace: true }, 'foo <' + el + '>baz ' + el + '>bar
');
- test_minify_sync(assert, 'foo<' + el + '> baz ' + el + '>bar
', { collapseWhitespace: true }, 'foo<' + el + '> baz ' + el + '>bar
');
- test_minify_sync(assert, 'foo <' + el + '> baz ' + el + '>bar
', { collapseWhitespace: true }, 'foo <' + el + '>baz ' + el + '>bar
');
- test_minify_sync(assert, 'foo<' + el + '> baz ' + el + '> bar
', { collapseWhitespace: true }, 'foo<' + el + '> baz ' + el + '>bar
');
+ test_minify(assert, 'foo <' + el + '>baz' + el + '> bar', 'foo <' + el + '>baz' + el + '> bar', { collapseWhitespace: true });
+ test_minify(assert, 'foo<' + el + '>baz' + el + '>bar', 'foo<' + el + '>baz' + el + '>bar', { collapseWhitespace: true });
+ test_minify(assert, 'foo <' + el + '>baz' + el + '>bar', 'foo <' + el + '>baz' + el + '>bar', { collapseWhitespace: true });
+ test_minify(assert, 'foo<' + el + '>baz' + el + '> bar', 'foo<' + el + '>baz' + el + '> bar', { collapseWhitespace: true });
+ test_minify(assert, 'foo <' + el + '> baz ' + el + '> bar', 'foo <' + el + '>baz ' + el + '>bar', { collapseWhitespace: true });
+ test_minify(assert, 'foo<' + el + '> baz ' + el + '>bar', 'foo<' + el + '> baz ' + el + '>bar', { collapseWhitespace: true });
+ test_minify(assert, 'foo <' + el + '> baz ' + el + '>bar', 'foo <' + el + '>baz ' + el + '>bar', { collapseWhitespace: true });
+ test_minify(assert, 'foo<' + el + '> baz ' + el + '> bar', 'foo<' + el + '> baz ' + el + '>bar', { collapseWhitespace: true });
+ test_minify(assert, 'foo <' + el + '>baz' + el + '> bar
', 'foo <' + el + '>baz' + el + '> bar
', { collapseWhitespace: true });
+ test_minify(assert, 'foo<' + el + '>baz' + el + '>bar
', 'foo<' + el + '>baz' + el + '>bar
', { collapseWhitespace: true });
+ test_minify(assert, 'foo <' + el + '>baz' + el + '>bar
', 'foo <' + el + '>baz' + el + '>bar
', { collapseWhitespace: true });
+ test_minify(assert, 'foo<' + el + '>baz' + el + '> bar
', 'foo<' + el + '>baz' + el + '> bar
', { collapseWhitespace: true });
+ test_minify(assert, 'foo <' + el + '> baz ' + el + '> bar
', 'foo <' + el + '>baz ' + el + '>bar
', { collapseWhitespace: true });
+ test_minify(assert, 'foo<' + el + '> baz ' + el + '>bar
', 'foo<' + el + '> baz ' + el + '>bar
', { collapseWhitespace: true });
+ test_minify(assert, 'foo <' + el + '> baz ' + el + '>bar
', 'foo <' + el + '>baz ' + el + '>bar
', { collapseWhitespace: true });
+ test_minify(assert, 'foo<' + el + '> baz ' + el + '> bar
', 'foo<' + el + '> baz ' + el + '>bar
', { collapseWhitespace: true });
});
// Don't trim whitespace around element, but do trim within
[
'bdi', 'bdo', 'button', 'cite', 'code', 'dfn', 'math', 'q', 'rt', 'rtc', 'ruby', 'svg'
].forEach(function(el) {
- test_minify_sync(assert, 'foo <' + el + '>baz' + el + '> bar', { collapseWhitespace: true }, 'foo <' + el + '>baz' + el + '> bar');
- test_minify_sync(assert, 'foo<' + el + '>baz' + el + '>bar', { collapseWhitespace: true }, 'foo<' + el + '>baz' + el + '>bar');
- test_minify_sync(assert, 'foo <' + el + '>baz' + el + '>bar', { collapseWhitespace: true }, 'foo <' + el + '>baz' + el + '>bar');
- test_minify_sync(assert, 'foo<' + el + '>baz' + el + '> bar', { collapseWhitespace: true }, 'foo<' + el + '>baz' + el + '> bar');
- test_minify_sync(assert, 'foo <' + el + '> baz ' + el + '> bar', { collapseWhitespace: true }, 'foo <' + el + '>baz' + el + '> bar');
- test_minify_sync(assert, 'foo<' + el + '> baz ' + el + '>bar', { collapseWhitespace: true }, 'foo<' + el + '>baz' + el + '>bar');
- test_minify_sync(assert, 'foo <' + el + '> baz ' + el + '>bar', { collapseWhitespace: true }, 'foo <' + el + '>baz' + el + '>bar');
- test_minify_sync(assert, 'foo<' + el + '> baz ' + el + '> bar', { collapseWhitespace: true }, 'foo<' + el + '>baz' + el + '> bar');
- test_minify_sync(assert, 'foo <' + el + '>baz' + el + '> bar
', { collapseWhitespace: true }, 'foo <' + el + '>baz' + el + '> bar
');
- test_minify_sync(assert, 'foo<' + el + '>baz' + el + '>bar
', { collapseWhitespace: true }, 'foo<' + el + '>baz' + el + '>bar
');
- test_minify_sync(assert, 'foo <' + el + '>baz' + el + '>bar
', { collapseWhitespace: true }, 'foo <' + el + '>baz' + el + '>bar
');
- test_minify_sync(assert, 'foo<' + el + '>baz' + el + '> bar
', { collapseWhitespace: true }, 'foo<' + el + '>baz' + el + '> bar
');
- test_minify_sync(assert, 'foo <' + el + '> baz ' + el + '> bar
', { collapseWhitespace: true }, 'foo <' + el + '>baz' + el + '> bar
');
- test_minify_sync(assert, 'foo<' + el + '> baz ' + el + '>bar
', { collapseWhitespace: true }, 'foo<' + el + '>baz' + el + '>bar
');
- test_minify_sync(assert, 'foo <' + el + '> baz ' + el + '>bar
', { collapseWhitespace: true }, 'foo <' + el + '>baz' + el + '>bar
');
- test_minify_sync(assert, 'foo<' + el + '> baz ' + el + '> bar
', { collapseWhitespace: true }, 'foo<' + el + '>baz' + el + '> bar
');
+ test_minify(assert, 'foo <' + el + '>baz' + el + '> bar', 'foo <' + el + '>baz' + el + '> bar', { collapseWhitespace: true });
+ test_minify(assert, 'foo<' + el + '>baz' + el + '>bar', 'foo<' + el + '>baz' + el + '>bar', { collapseWhitespace: true });
+ test_minify(assert, 'foo <' + el + '>baz' + el + '>bar', 'foo <' + el + '>baz' + el + '>bar', { collapseWhitespace: true });
+ test_minify(assert, 'foo<' + el + '>baz' + el + '> bar', 'foo<' + el + '>baz' + el + '> bar', { collapseWhitespace: true });
+ test_minify(assert, 'foo <' + el + '> baz ' + el + '> bar', 'foo <' + el + '>baz' + el + '> bar', { collapseWhitespace: true });
+ test_minify(assert, 'foo<' + el + '> baz ' + el + '>bar', 'foo<' + el + '>baz' + el + '>bar', { collapseWhitespace: true });
+ test_minify(assert, 'foo <' + el + '> baz ' + el + '>bar', 'foo <' + el + '>baz' + el + '>bar', { collapseWhitespace: true });
+ test_minify(assert, 'foo<' + el + '> baz ' + el + '> bar', 'foo<' + el + '>baz' + el + '> bar', { collapseWhitespace: true });
+ test_minify(assert, 'foo <' + el + '>baz' + el + '> bar
', 'foo <' + el + '>baz' + el + '> bar
', { collapseWhitespace: true });
+ test_minify(assert, 'foo<' + el + '>baz' + el + '>bar
', 'foo<' + el + '>baz' + el + '>bar
', { collapseWhitespace: true });
+ test_minify(assert, 'foo <' + el + '>baz' + el + '>bar
', 'foo <' + el + '>baz' + el + '>bar
', { collapseWhitespace: true });
+ test_minify(assert, 'foo<' + el + '>baz' + el + '> bar
', 'foo<' + el + '>baz' + el + '> bar
', { collapseWhitespace: true });
+ test_minify(assert, 'foo <' + el + '> baz ' + el + '> bar
', 'foo <' + el + '>baz' + el + '> bar
', { collapseWhitespace: true });
+ test_minify(assert, 'foo<' + el + '> baz ' + el + '>bar
', 'foo<' + el + '>baz' + el + '>bar
', { collapseWhitespace: true });
+ test_minify(assert, 'foo <' + el + '> baz ' + el + '>bar
', 'foo <' + el + '>baz' + el + '>bar
', { collapseWhitespace: true });
+ test_minify(assert, 'foo<' + el + '> baz ' + el + '> bar
', 'foo<' + el + '>baz' + el + '> bar
', { collapseWhitespace: true });
});
[
[' foo ', 'foo'],
@@ -466,39 +468,39 @@ QUnit.test('space normalization around text', function(assert) {
['a b c', 'a b c'],
['a b c', 'a b c']
].forEach(function(inputs) {
- test_minify_sync(assert, inputs[0], {
+ test_minify(assert, inputs[0], inputs[0], {
collapseWhitespace: true,
conservativeCollapse: true
- }, inputs[0], inputs[0]);
- test_minify_sync(assert, inputs[0], { collapseWhitespace: true }, inputs[1], inputs[0]);
+ }, inputs[0]);
+ test_minify(assert, inputs[0], inputs[1], { collapseWhitespace: true }, inputs[0]);
var input = '' + inputs[0] + '
';
- test_minify_sync(assert, input, {
+ test_minify(assert, input, input, {
collapseWhitespace: true,
conservativeCollapse: true
- }, input, input);
+ }, input);
var output = '' + inputs[1] + '
';
- test_minify_sync(assert, input, { collapseWhitespace: true }, output, input);
- });
- test_minify_sync(assert, 'foo
bar
', { collapseWhitespace: true }, 'foo
bar
');
- test_minify_sync(assert, 'foo
bar
', { collapseWhitespace: true }, 'foo
bar
');
- test_minify_sync(assert, 'foo
bar
', { collapseWhitespace: true }, 'foo
bar
');
- test_minify_sync(assert, 'foo
bar
', { collapseWhitespace: true }, 'foo
bar
');
- test_minify_sync(assert, 'foo bar
', { collapseWhitespace: true }, 'foo bar
');
- test_minify_sync(assert, 'foobar
', { collapseWhitespace: true }, 'foobar
');
- test_minify_sync(assert, 'foo bar
', { collapseWhitespace: true }, 'foo bar
');
- test_minify_sync(assert, 'foo bar
', { collapseWhitespace: true }, 'foo bar
');
- test_minify_sync(assert, 'foo bar
', { collapseWhitespace: true }, 'foo bar
');
- test_minify_sync(assert, 'foobar
', { collapseWhitespace: true }, 'foobar
');
- test_minify_sync(assert, 'foo bar
', { collapseWhitespace: true }, 'foo bar
');
- test_minify_sync(assert, 'foo bar
', { collapseWhitespace: true }, 'foo bar
');
- test_minify_sync(assert, ' foo
bar
', { collapseWhitespace: true }, 'foo
bar
');
- test_minify_sync(assert, 'foo
bar
', { collapseWhitespace: true }, 'foo
bar
');
- test_minify_sync(assert, ' foo
bar
', { collapseWhitespace: true }, 'foo
bar
');
- test_minify_sync(assert, ' Empty not
', { collapseWhitespace: true }, 'Empty not
');
- test_minify_sync(assert, ' a c
', {
+ test_minify(assert, input, output, { collapseWhitespace: true }, input);
+ });
+ test_minify(assert, 'foo
bar
', 'foo
bar
', { collapseWhitespace: true });
+ test_minify(assert, 'foo
bar
', 'foo
bar
', { collapseWhitespace: true });
+ test_minify(assert, 'foo
bar
', 'foo
bar
', { collapseWhitespace: true });
+ test_minify(assert, 'foo
bar
', 'foo
bar
', { collapseWhitespace: true });
+ test_minify(assert, 'foo bar
', 'foo bar
', { collapseWhitespace: true });
+ test_minify(assert, 'foobar
', 'foobar
', { collapseWhitespace: true });
+ test_minify(assert, 'foo bar
', 'foo bar
', { collapseWhitespace: true });
+ test_minify(assert, 'foo bar
', 'foo bar
', { collapseWhitespace: true });
+ test_minify(assert, 'foo bar
', 'foo bar
', { collapseWhitespace: true });
+ test_minify(assert, 'foobar
', 'foobar
', { collapseWhitespace: true });
+ test_minify(assert, 'foo bar
', 'foo bar
', { collapseWhitespace: true });
+ test_minify(assert, 'foo bar
', 'foo bar
', { collapseWhitespace: true });
+ test_minify(assert, ' foo
bar
', 'foo
bar
', { collapseWhitespace: true });
+ test_minify(assert, 'foo
bar
', 'foo
bar
', { collapseWhitespace: true });
+ test_minify(assert, ' foo
bar
', 'foo
bar
', { collapseWhitespace: true });
+ test_minify(assert, ' Empty not
', 'Empty not
', { collapseWhitespace: true });
+ test_minify(assert, ' a c
', 'a c
', {
collapseWhitespace: true,
removeComments: true
- }, 'a c
');
+ });
[
' a b ?> c ',
' a b ?> c ',
@@ -510,64 +512,64 @@ QUnit.test('space normalization around text', function(assert) {
' a b ?> c ',
' a b ?> c '
].forEach(function(input) {
- test_minify_sync(assert, input, {
+ test_minify(assert, input, input, {
collapseWhitespace: true,
conservativeCollapse: true
- }, input, input);
- test_minify_sync(assert, input, {
+ }, input);
+ test_minify(assert, input, 'a b ?> c', {
collapseWhitespace: true,
removeComments: true
- }, 'a b ?> c', input);
- test_minify_sync(assert, input, {
+ }, input);
+ test_minify(assert, input, ' a b ?> c ', {
collapseWhitespace: true,
conservativeCollapse: true,
removeComments: true
- }, ' a b ?> c ', input);
+ }, input);
input = '' + input + '
';
- test_minify_sync(assert, input, {
+ test_minify(assert, input, input, {
collapseWhitespace: true,
conservativeCollapse: true
- }, input, input);
- test_minify_sync(assert, input, {
+ }, input);
+ test_minify(assert, input, 'a b ?> c
', {
collapseWhitespace: true,
removeComments: true
- }, 'a b ?> c
', input);
- test_minify_sync(assert, input, {
+ }, input);
+ test_minify(assert, input, ' a b ?> c
', {
collapseWhitespace: true,
conservativeCollapse: true,
removeComments: true
- }, ' a b ?> c
', input);
+ }, input);
});
input = ' foo';
output = ' foo';
- test_minify_sync(assert, input, { collapseWhitespace: true }, output);
+ test_minify(assert, input, output, { collapseWhitespace: true });
input = ' foo';
- test_minify_sync(assert, input, { collapseWhitespace: true }, output);
+ test_minify(assert, input, output, { collapseWhitespace: true });
input = ' foo';
- test_minify_sync(assert, input, { collapseWhitespace: true }, output);
+ test_minify(assert, input, output, { collapseWhitespace: true });
input = ' foo';
- test_minify_sync(assert, input, { collapseWhitespace: true }, output);
+ test_minify(assert, input, output, { collapseWhitespace: true });
input = ' foo';
- test_minify_sync(assert, input, { collapseWhitespace: true }, output);
+ test_minify(assert, input, output, { collapseWhitespace: true });
input = '';
output = '';
- test_minify_sync(assert, input, { collapseWhitespace: true }, output);
+ test_minify(assert, input, output, { collapseWhitespace: true });
input = ' ';
output = '';
- test_minify_sync(assert, input, { collapseWhitespace: true }, output);
+ test_minify(assert, input, output, { collapseWhitespace: true });
input = ' ';
output = '';
- test_minify_sync(assert, input, { collapseWhitespace: true }, output);
+ test_minify(assert, input, output, { collapseWhitespace: true });
input = ' foo\u00A0bar\nbaz \u00A0\nmoo\t
';
output = 'foo\u00A0bar baz \u00A0 moo
';
- test_minify_sync(assert, input, { collapseWhitespace: true }, output);
+ test_minify(assert, input, output, { collapseWhitespace: true });
input = '\n' +
'\n' +
'\n' +
'\n' +
'\n';
output = ' ';
- test_minify_sync(assert, input, { collapseWhitespace: true }, output);
+ test_minify(assert, input, output, { collapseWhitespace: true });
input = '\n' +
'foo\n' +
'
\n' +
@@ -575,130 +577,130 @@ QUnit.test('space normalization around text', function(assert) {
'
\n' +
'baz\n';
output = '\nfoo\n
\nbar\n
baz';
- test_minify_sync(assert, input, { collapseWhitespace: true }, output);
+ test_minify(assert, input, output, { collapseWhitespace: true });
});
QUnit.test('types of whitespace that should always be preserved', function(assert) {
// Hair space:
var input = '\u200afo\u200ao\u200a
';
- test_minify_sync(assert, input, { collapseWhitespace: true }, input);
+ test_minify(assert, input, input, { collapseWhitespace: true });
// Hair space passed as HTML entity:
var inputWithEntities = ' fo o
';
- test_minify_sync(assert, inputWithEntities, { collapseWhitespace: true }, inputWithEntities);
+ test_minify(assert, inputWithEntities, inputWithEntities, { collapseWhitespace: true });
// Hair space passed as HTML entity, in decodeEntities:true mode:
- test_minify_sync(assert, inputWithEntities, { collapseWhitespace: true, decodeEntities: true }, input);
+ test_minify(assert, inputWithEntities, input, { collapseWhitespace: true, decodeEntities: true });
// Non-breaking space:
input = '\xa0fo\xa0o\xa0
';
- test_minify_sync(assert, input, { collapseWhitespace: true }, input);
+ test_minify(assert, input, input, { collapseWhitespace: true });
// Non-breaking space passed as HTML entity:
inputWithEntities = ' fo o
';
- test_minify_sync(assert, inputWithEntities, { collapseWhitespace: true }, inputWithEntities);
+ test_minify(assert, inputWithEntities, inputWithEntities, { collapseWhitespace: true });
// Non-breaking space passed as HTML entity, in decodeEntities:true mode:
- test_minify_sync(assert, inputWithEntities, { collapseWhitespace: true, decodeEntities: true }, input);
+ test_minify(assert, inputWithEntities, input, { collapseWhitespace: true, decodeEntities: true });
// Do not remove hair space when preserving line breaks between tags:
input = '\u200a\n\n';
- test_minify_sync(assert, input, { collapseWhitespace: true, preserveLineBreaks: true }, input);
+ test_minify(assert, input, input, { collapseWhitespace: true, preserveLineBreaks: true });
// Preserve hair space in attributes:
input = '';
- test_minify_sync(assert, input, { collapseWhitespace: true }, input);
+ test_minify(assert, input, input, { collapseWhitespace: true });
// Preserve hair space in class names when deduplicating and reordering:
input = '';
- test_minify_sync(assert, input, { sortClassName: false }, input);
- test_minify_sync(assert, input, { sortClassName: true }, input);
+ test_minify(assert, input, input, { sortClassName: false });
+ test_minify(assert, input, input, { sortClassName: true });
});
QUnit.test('doctype normalization', function(assert) {
var input;
input = '';
- test_minify_sync(assert, input, { useShortDoctype: true }, '');
+ test_minify(assert, input, '', { useShortDoctype: true });
input = '';
- test_minify_sync(assert, input, { useShortDoctype: true }, input);
+ test_minify(assert, input, input, { useShortDoctype: true });
input = '';
- test_minify_sync(assert, input, { useShortDoctype: false }, input);
+ test_minify(assert, input, input, { useShortDoctype: false });
});
QUnit.test('removing comments', function(assert) {
var input;
input = '';
- test_minify_sync(assert, input, { removeComments: true }, '');
+ test_minify(assert, input, '', { removeComments: true });
input = 'baz
';
- test_minify_sync(assert, input, { removeComments: true }, 'baz
');
- test_minify_sync(assert, input, { removeComments: false }, input);
+ test_minify(assert, input, 'baz
', { removeComments: true });
+ test_minify(assert, input, input, { removeComments: false });
input = 'foo
';
- test_minify_sync(assert, input, { removeComments: true }, input);
+ test_minify(assert, input, input, { removeComments: true });
input = '';
- test_minify_sync(assert, input, { removeComments: true }, input);
+ test_minify(assert, input, input, { removeComments: true });
input = '';
- test_minify_sync(assert, input, { removeComments: true }, '');
+ test_minify(assert, input, '', { removeComments: true });
});
QUnit.test('ignoring comments', function(assert) {
var input, output;
input = '';
- test_minify_sync(assert, input, { removeComments: true }, input);
- test_minify_sync(assert, input, { removeComments: false }, input);
+ test_minify(assert, input, input, { removeComments: true });
+ test_minify(assert, input, input, { removeComments: false });
input = 'baz
';
- test_minify_sync(assert, input, { removeComments: true }, input);
- test_minify_sync(assert, input, { removeComments: false }, input);
+ test_minify(assert, input, input, { removeComments: true });
+ test_minify(assert, input, input, { removeComments: false });
input = 'baz
';
- test_minify_sync(assert, input, { removeComments: true }, 'baz
');
- test_minify_sync(assert, input, { removeComments: false }, input);
+ test_minify(assert, input, 'baz
', { removeComments: true });
+ test_minify(assert, input, input, { removeComments: false });
input = '';
- test_minify_sync(assert, input, { removeComments: true }, '');
- test_minify_sync(assert, input, { removeComments: false }, input);
+ test_minify(assert, input, '', { removeComments: true });
+ test_minify(assert, input, input, { removeComments: false });
input = '';
output = '';
- test_minify_sync(assert, input, { removeComments: true }, input);
- test_minify_sync(assert, input, { removeComments: true, collapseWhitespace: true }, output);
- test_minify_sync(assert, input, { removeComments: false }, input);
- test_minify_sync(assert, input, { removeComments: false, collapseWhitespace: true }, output);
+ test_minify(assert, input, input, { removeComments: true });
+ test_minify(assert, input, output, { removeComments: true, collapseWhitespace: true });
+ test_minify(assert, input, input, { removeComments: false });
+ test_minify(assert, input, output, { removeComments: false, collapseWhitespace: true });
input = 'foo
';
- test_minify_sync(assert, input, { removeComments: true }, input);
+ test_minify(assert, input, input, { removeComments: true });
});
QUnit.test('conditional comments', function(assert) {
var input, output;
input = 'test';
- test_minify_sync(assert, input, { removeComments: true }, input);
+ test_minify(assert, input, input, { removeComments: true });
input = '';
- test_minify_sync(assert, input, { removeComments: true }, input);
+ test_minify(assert, input, input, { removeComments: true });
input = 'test';
- test_minify_sync(assert, input, { removeComments: true }, input);
+ test_minify(assert, input, input, { removeComments: true });
input = 'test';
- test_minify_sync(assert, input, { removeComments: true }, input);
+ test_minify(assert, input, input, { removeComments: true });
input = '';
- test_minify_sync(assert, input, { removeComments: true }, input);
+ test_minify(assert, input, input, { removeComments: true });
input = '';
- test_minify_sync(assert, input, { removeComments: true }, input);
+ test_minify(assert, input, input, { removeComments: true });
input = '\n' +
' \n' +
@@ -716,22 +718,22 @@ QUnit.test('conditional comments', function(assert) {
' alert("ie8!");\n' +
' \n' +
' ';
- test_minify_sync(assert, input, {
+ test_minify(assert, input, output, {
minifyJS: true,
removeComments: true,
collapseWhitespace: true,
removeOptionalTags: true,
removeScriptTypeAttributes: true
- }, output);
+ });
output = '';
- test_minify_sync(assert, input, {
+ test_minify(assert, input, output, {
minifyJS: true,
removeComments: true,
collapseWhitespace: true,
removeOptionalTags: true,
removeScriptTypeAttributes: true,
processConditionalComments: true
- }, output);
+ });
input = '\n' +
'\n' +
@@ -759,15 +761,15 @@ QUnit.test('conditional comments', function(assert) {
'' +
'' +
'Document';
- test_minify_sync(assert, input, {
+ test_minify(assert, input, output, {
removeComments: true,
collapseWhitespace: true
- }, output);
- test_minify_sync(assert, input, {
+ });
+ test_minify(assert, input, output, {
removeComments: true,
collapseWhitespace: true,
processConditionalComments: true
- }, output);
+ });
});
QUnit.test('collapsing space in conditional comments', function(assert) {
@@ -776,215 +778,215 @@ QUnit.test('collapsing space in conditional comments', function(assert) {
input = '';
- test_minify_sync(assert, input, { removeComments: true }, input);
- test_minify_sync(assert, input, { removeComments: true, collapseWhitespace: true }, input);
+ test_minify(assert, input, input, { removeComments: true });
+ test_minify(assert, input, input, { removeComments: true, collapseWhitespace: true });
output = '';
- test_minify_sync(assert, input, { removeComments: true, processConditionalComments: true }, output);
+ test_minify(assert, input, output, { removeComments: true, processConditionalComments: true });
output = '';
- test_minify_sync(assert, input, {
+ test_minify(assert, input, output, {
removeComments: true,
collapseWhitespace: true,
processConditionalComments: true
- }, output);
+ });
input = '';
- test_minify_sync(assert, input, { removeComments: true }, input);
- test_minify_sync(assert, input, { removeComments: true, collapseWhitespace: true }, input);
+ test_minify(assert, input, input, { removeComments: true });
+ test_minify(assert, input, input, { removeComments: true, collapseWhitespace: true });
output = '';
- test_minify_sync(assert, input, {
+ test_minify(assert, input, output, {
removeComments: true,
collapseWhitespace: true,
processConditionalComments: true
- }, output);
+ });
});
QUnit.test('remove comments from scripts', function(assert) {
var input, output;
input = '';
- test_minify_sync(assert, input, input);
+ test_minify(assert, input, input);
output = '';
- test_minify_sync(assert, input, { minifyJS: true }, output);
+ test_minify(assert, input, output, { minifyJS: true });
input = '';
- test_minify_sync(assert, input, input);
+ test_minify(assert, input, input);
output = '';
- test_minify_sync(assert, input, { minifyJS: true }, output);
+ test_minify(assert, input, output, { minifyJS: true });
input = '';
- test_minify_sync(assert, input, input);
+ test_minify(assert, input, input);
output = '';
- test_minify_sync(assert, input, { minifyJS: true }, output);
+ test_minify(assert, input, output, { minifyJS: true });
input = '';
- test_minify_sync(assert, input, input);
- test_minify_sync(assert, input, { minifyJS: true }, input);
+ test_minify(assert, input, input);
+ test_minify(assert, input, input, { minifyJS: true });
input = '';
- test_minify_sync(assert, input, input);
- test_minify_sync(assert, input, { minifyJS: true }, input);
+ test_minify(assert, input, input);
+ test_minify(assert, input, input, { minifyJS: true });
input = '';
- test_minify_sync(assert, input, input);
+ test_minify(assert, input, input);
output = '';
- test_minify_sync(assert, input, { minifyJS: true }, output);
+ test_minify(assert, input, output, { minifyJS: true });
input = '';
- test_minify_sync(assert, input, input);
- test_minify_sync(assert, input, { minifyJS: true }, input);
+ test_minify(assert, input, input);
+ test_minify(assert, input, input, { minifyJS: true });
input = '';
- test_minify_sync(assert, input, input);
+ test_minify(assert, input, input);
output = '';
- test_minify_sync(assert, input, { minifyJS: true }, output);
+ test_minify(assert, input, output, { minifyJS: true });
input = '';
- test_minify_sync(assert, input, input);
+ test_minify(assert, input, input);
output = '';
- test_minify_sync(assert, input, { minifyJS: true }, output);
+ test_minify(assert, input, output, { minifyJS: true });
input = '';
- test_minify_sync(assert, input, input);
- test_minify_sync(assert, input, { minifyJS: true }, input);
+ test_minify(assert, input, input);
+ test_minify(assert, input, input, { minifyJS: true });
});
QUnit.test('remove comments from styles', function(assert) {
var input, output;
input = '';
- test_minify_sync(assert, input, input);
+ test_minify(assert, input, input);
output = '';
- test_minify_sync(assert, input, { minifyCSS: true }, output);
+ test_minify(assert, input, output, { minifyCSS: true });
input = '';
- test_minify_sync(assert, input, input);
+ test_minify(assert, input, input);
output = '';
- test_minify_sync(assert, input, { minifyCSS: true }, output);
+ test_minify(assert, input, output, { minifyCSS: true });
input = '';
- test_minify_sync(assert, input, input);
+ test_minify(assert, input, input);
output = '';
- test_minify_sync(assert, input, { minifyCSS: true }, output);
+ test_minify(assert, input, output, { minifyCSS: true });
input = '';
- test_minify_sync(assert, input, input);
+ test_minify(assert, input, input);
output = '';
- test_minify_sync(assert, input, { minifyCSS: true }, output);
+ test_minify(assert, input, output, { minifyCSS: true });
input = '';
- test_minify_sync(assert, input, input);
+ test_minify(assert, input, input);
output = '';
- test_minify_sync(assert, input, { minifyCSS: true }, output);
+ test_minify(assert, input, output, { minifyCSS: true });
input = '';
- test_minify_sync(assert, input, input);
+ test_minify(assert, input, input);
output = '';
- test_minify_sync(assert, input, { minifyCSS: true }, output);
+ test_minify(assert, input, output, { minifyCSS: true });
input = '';
- test_minify_sync(assert, input, input);
+ test_minify(assert, input, input);
output = '';
- test_minify_sync(assert, input, { minifyCSS: true }, output);
+ test_minify(assert, input, output, { minifyCSS: true });
input = '';
- test_minify_sync(assert, input, input);
+ test_minify(assert, input, input);
output = '';
- test_minify_sync(assert, input, { minifyCSS: true }, output);
+ test_minify(assert, input, output, { minifyCSS: true });
input = '';
- test_minify_sync(assert, input, input);
- test_minify_sync(assert, input, { minifyCSS: true }, input);
+ test_minify(assert, input, input);
+ test_minify(assert, input, input, { minifyCSS: true });
});
QUnit.test('remove CDATA sections from scripts/styles', function(assert) {
var input, output;
input = '';
- test_minify_sync(assert, input, input);
- test_minify_sync(assert, input, { minifyJS: true }, input);
+ test_minify(assert, input, input);
+ test_minify(assert, input, input, { minifyJS: true });
input = '';
- test_minify_sync(assert, input, input);
- test_minify_sync(assert, input, { minifyJS: true }, input);
+ test_minify(assert, input, input);
+ test_minify(assert, input, input, { minifyJS: true });
input = '';
- test_minify_sync(assert, input, input);
- test_minify_sync(assert, input, { minifyJS: true }, input);
+ test_minify(assert, input, input);
+ test_minify(assert, input, input, { minifyJS: true });
input = '';
- test_minify_sync(assert, input, input);
- test_minify_sync(assert, input, { minifyJS: true }, input);
+ test_minify(assert, input, input);
+ test_minify(assert, input, input, { minifyJS: true });
input = '';
- test_minify_sync(assert, input, input);
- test_minify_sync(assert, input, { minifyJS: true }, input);
+ test_minify(assert, input, input);
+ test_minify(assert, input, input, { minifyJS: true });
input = '';
- test_minify_sync(assert, input, input);
+ test_minify(assert, input, input);
output = '';
- test_minify_sync(assert, input, { minifyJS: true }, output);
+ test_minify(assert, input, output, { minifyJS: true });
input = '';
- test_minify_sync(assert, input, input);
+ test_minify(assert, input, input);
output = '';
- test_minify_sync(assert, input, { minifyJS: true }, output);
+ test_minify(assert, input, output, { minifyJS: true });
input = '';
- test_minify_sync(assert, input, input);
+ test_minify(assert, input, input);
output = '';
- test_minify_sync(assert, input, { minifyJS: true }, output);
+ test_minify(assert, input, output, { minifyJS: true });
input = '';
- test_minify_sync(assert, input, input);
+ test_minify(assert, input, input);
output = '';
- test_minify_sync(assert, input, { minifyJS: true }, output);
+ test_minify(assert, input, output, { minifyJS: true });
input = '';
- test_minify_sync(assert, input, input);
+ test_minify(assert, input, input);
output = '';
- test_minify_sync(assert, input, { minifyCSS: true }, output);
+ test_minify(assert, input, output, { minifyCSS: true });
input = '';
- test_minify_sync(assert, input, input);
+ test_minify(assert, input, input);
output = '';
- test_minify_sync(assert, input, { minifyCSS: true }, output);
+ test_minify(assert, input, output, { minifyCSS: true });
input = '';
- test_minify_sync(assert, input, input);
+ test_minify(assert, input, input);
output = '';
- test_minify_sync(assert, input, { minifyCSS: true }, output);
+ test_minify(assert, input, output, { minifyCSS: true });
input = '';
- test_minify_sync(assert, input, input);
+ test_minify(assert, input, input);
output = '';
- test_minify_sync(assert, input, { minifyCSS: true }, output);
+ test_minify(assert, input, output, { minifyCSS: true });
input = '';
- test_minify_sync(assert, input, input);
+ test_minify(assert, input, input);
output = '';
- test_minify_sync(assert, input, { minifyCSS: true }, output);
+ test_minify(assert, input, output, { minifyCSS: true });
input = '';
- test_minify_sync(assert, input, input);
+ test_minify(assert, input, input);
output = '';
- test_minify_sync(assert, input, { minifyCSS: true }, output);
+ test_minify(assert, input, output, { minifyCSS: true });
input = '';
- test_minify_sync(assert, input, input);
+ test_minify(assert, input, input);
output = '';
- test_minify_sync(assert, input, { minifyCSS: true }, output);
+ test_minify(assert, input, output, { minifyCSS: true });
input = '';
- test_minify_sync(assert, input, input);
- test_minify_sync(assert, input, { minifyCSS: true }, input);
+ test_minify(assert, input, input);
+ test_minify(assert, input, input, { minifyCSS: true });
});
QUnit.test('custom processors', function(assert) {
@@ -995,125 +997,125 @@ QUnit.test('custom processors', function(assert) {
}
input = '';
- test_minify_sync(assert, input, input);
- test_minify_sync(assert, input, { minifyCSS: null }, input);
- test_minify_sync(assert, input, { minifyCSS: false }, input);
+ test_minify(assert, input, input);
+ test_minify(assert, input, input, { minifyCSS: null });
+ test_minify(assert, input, input, { minifyCSS: false });
output = '';
- test_minify_sync(assert, input, { minifyCSS: css }, output);
+ test_minify(assert, input, output, { minifyCSS: css });
input = '';
- test_minify_sync(assert, input, input);
- test_minify_sync(assert, input, { minifyCSS: null }, input);
- test_minify_sync(assert, input, { minifyCSS: false }, input);
+ test_minify(assert, input, input);
+ test_minify(assert, input, input, { minifyCSS: null });
+ test_minify(assert, input, input, { minifyCSS: false });
output = '';
- test_minify_sync(assert, input, { minifyCSS: css }, output);
+ test_minify(assert, input, output, { minifyCSS: css });
input = '';
- test_minify_sync(assert, input, input);
- test_minify_sync(assert, input, { minifyCSS: null }, input);
- test_minify_sync(assert, input, { minifyCSS: false }, input);
+ test_minify(assert, input, input);
+ test_minify(assert, input, input, { minifyCSS: null });
+ test_minify(assert, input, input, { minifyCSS: false });
output = '';
- test_minify_sync(assert, input, { minifyCSS: css }, output);
+ test_minify(assert, input, output, { minifyCSS: css });
input = '';
- test_minify_sync(assert, input, input);
- test_minify_sync(assert, input, { minifyCSS: null }, input);
- test_minify_sync(assert, input, { minifyCSS: false }, input);
+ test_minify(assert, input, input);
+ test_minify(assert, input, input, { minifyCSS: null });
+ test_minify(assert, input, input, { minifyCSS: false });
output = '';
- test_minify_sync(assert, input, { minifyCSS: css }, output);
+ test_minify(assert, input, output, { minifyCSS: css });
function js(text, inline) {
return inline ? 'Inline JS' : 'Normal JS';
}
input = '';
- test_minify_sync(assert, input, input);
- test_minify_sync(assert, input, { minifyJS: null }, input);
- test_minify_sync(assert, input, { minifyJS: false }, input);
+ test_minify(assert, input, input);
+ test_minify(assert, input, input, { minifyJS: null });
+ test_minify(assert, input, input, { minifyJS: false });
output = '';
- test_minify_sync(assert, input, { minifyJS: js }, output);
+ test_minify(assert, input, output, { minifyJS: js });
input = '';
- test_minify_sync(assert, input, input);
- test_minify_sync(assert, input, { minifyJS: null }, input);
- test_minify_sync(assert, input, { minifyJS: false }, input);
+ test_minify(assert, input, input);
+ test_minify(assert, input, input, { minifyJS: null });
+ test_minify(assert, input, input, { minifyJS: false });
output = '';
- test_minify_sync(assert, input, { minifyJS: js }, output);
+ test_minify(assert, input, output, { minifyJS: js });
function url() {
return 'URL';
}
input = 'bar';
- test_minify_sync(assert, input, input);
- test_minify_sync(assert, input, { minifyURLs: null }, input);
- test_minify_sync(assert, input, { minifyURLs: false }, input);
+ test_minify(assert, input, input);
+ test_minify(assert, input, input, { minifyURLs: null });
+ test_minify(assert, input, input, { minifyURLs: false });
output = 'bar';
- test_minify_sync(assert, input, { minifyURLs: url }, output);
+ test_minify(assert, input, output, { minifyURLs: url });
input = '';
- test_minify_sync(assert, input, input);
- test_minify_sync(assert, input, { minifyURLs: null }, input);
- test_minify_sync(assert, input, { minifyURLs: false }, input);
- test_minify_sync(assert, input, { minifyURLs: url }, input);
+ test_minify(assert, input, input);
+ test_minify(assert, input, input, { minifyURLs: null });
+ test_minify(assert, input, input, { minifyURLs: false });
+ test_minify(assert, input, input, { minifyURLs: url });
output = '';
- test_minify_sync(assert, input, { minifyCSS: true, minifyURLs: url }, output);
+ test_minify(assert, input, output, { minifyCSS: true, minifyURLs: url });
});
QUnit.test('empty attributes', function(assert) {
var input;
input = 'x
';
- test_minify_sync(assert, input, { removeEmptyAttributes: true }, 'x
');
+ test_minify(assert, input, 'x
', { removeEmptyAttributes: true });
input = 'x
';
- test_minify_sync(assert, input, { removeEmptyAttributes: true }, 'x
');
+ test_minify(assert, input, 'x
', { removeEmptyAttributes: true });
input = '';
- test_minify_sync(assert, input, { removeEmptyAttributes: true }, '');
+ test_minify(assert, input, '', { removeEmptyAttributes: true });
input = '';
- test_minify_sync(assert, input, { removeEmptyAttributes: true }, '');
+ test_minify(assert, input, '', { removeEmptyAttributes: true });
input = '
';
- test_minify_sync(assert, input, { removeEmptyAttributes: true }, '
');
+ test_minify(assert, input, '
', { removeEmptyAttributes: true });
// preserve unrecognized attribute
// remove recognized attrs with unspecified values
input = '';
- test_minify_sync(assert, input, { removeEmptyAttributes: true }, '');
+ test_minify(assert, input, '', { removeEmptyAttributes: true });
// additional remove attributes
input = '
';
- test_minify_sync(assert, input, { removeEmptyAttributes: function(attrName, tag) { return tag === 'img' && attrName === 'src'; } }, '
');
+ test_minify(assert, input, '
', { removeEmptyAttributes: function(attrName, tag) { return tag === 'img' && attrName === 'src'; } });
});
QUnit.test('cleaning class/style attributes', function(assert) {
var input, output;
input = 'foo bar baz
';
- test_minify_sync(assert, input, 'foo bar baz
');
+ test_minify(assert, input, 'foo bar baz
');
input = 'foo bar baz
';
- test_minify_sync(assert, input, 'foo bar baz
');
- test_minify_sync(assert, input, { removeAttributeQuotes: true }, 'foo bar baz
');
+ test_minify(assert, input, 'foo bar baz
');
+ test_minify(assert, input, 'foo bar baz
', { removeAttributeQuotes: true });
input = 'foo bar baz
';
output = 'foo bar baz
';
- test_minify_sync(assert, input, output);
+ test_minify(assert, input, output);
input = 'foo bar baz
';
output = 'foo bar baz
';
- test_minify_sync(assert, input, output);
+ test_minify(assert, input, output);
input = '';
output = '';
- test_minify_sync(assert, input, output);
+ test_minify(assert, input, output);
input = '';
output = '';
- test_minify_sync(assert, input, output);
+ test_minify(assert, input, output);
});
QUnit.test('cleaning URI-based attributes', function(assert) {
@@ -1121,41 +1123,41 @@ QUnit.test('cleaning URI-based attributes', function(assert) {
input = 'x';
output = 'x';
- test_minify_sync(assert, input, output);
+ test_minify(assert, input, output);
input = 'x';
output = 'x';
- test_minify_sync(assert, input, output);
+ test_minify(assert, input, output);
input = '
';
output = '
';
- test_minify_sync(assert, input, output);
+ test_minify(assert, input, output);
input = '
';
output = '
';
- test_minify_sync(assert, input, output);
+ test_minify(assert, input, output);
input = '';
output = '';
- test_minify_sync(assert, input, output);
+ test_minify(assert, input, output);
input = 'foobar
';
output = 'foobar
';
- test_minify_sync(assert, input, output);
+ test_minify(assert, input, output);
input = '';
output = '';
- test_minify_sync(assert, input, output);
+ test_minify(assert, input, output);
input = '';
output = '';
- test_minify_sync(assert, input, output);
+ test_minify(assert, input, output);
input = 'foo';
- test_minify_sync(assert, input, input);
+ test_minify(assert, input, input);
input = 'blah
';
- test_minify_sync(assert, input, input);
+ test_minify(assert, input, input);
});
QUnit.test('cleaning Number-based attributes', function(assert) {
@@ -1163,27 +1165,27 @@ QUnit.test('cleaning Number-based attributes', function(assert) {
input = 'x';
output = 'x';
- test_minify_sync(assert, input, output);
+ test_minify(assert, input, output);
input = '';
output = '';
- test_minify_sync(assert, input, output);
+ test_minify(assert, input, output);
input = '';
output = '';
- test_minify_sync(assert, input, output);
+ test_minify(assert, input, output);
input = '';
output = '';
- test_minify_sync(assert, input, output);
+ test_minify(assert, input, output);
input = '';
output = '';
- test_minify_sync(assert, input, output);
+ test_minify(assert, input, output);
input = 'x | |
';
output = 'x | |
';
- test_minify_sync(assert, input, output);
+ test_minify(assert, input, output);
});
QUnit.test('cleaning other attributes', function(assert) {
@@ -1191,50 +1193,50 @@ QUnit.test('cleaning other attributes', function(assert) {
input = 'blah';
output = 'blah';
- test_minify_sync(assert, input, output);
+ test_minify(assert, input, output);
input = 'x';
output = '
x
';
- test_minify_sync(assert, input, output);
+ test_minify(assert, input, output);
});
QUnit.test('removing redundant attributes (<form method="get" ...>)', function(assert) {
var input;
input = '';
- test_minify_sync(assert, input, { removeRedundantAttributes: true }, '');
+ test_minify(assert, input, '', { removeRedundantAttributes: true });
input = '';
- test_minify_sync(assert, input, { removeRedundantAttributes: true }, '');
+ test_minify(assert, input, '', { removeRedundantAttributes: true });
});
QUnit.test('removing redundant attributes (<input type="text" ...>)', function(assert) {
var input;
input = '';
- test_minify_sync(assert, input, { removeRedundantAttributes: true }, '');
+ test_minify(assert, input, '', { removeRedundantAttributes: true });
input = '';
- test_minify_sync(assert, input, { removeRedundantAttributes: true }, '');
+ test_minify(assert, input, '', { removeRedundantAttributes: true });
input = '';
- test_minify_sync(assert, input, { removeRedundantAttributes: true }, '');
+ test_minify(assert, input, '', { removeRedundantAttributes: true });
});
QUnit.test('removing redundant attributes (<a name="..." id="..." ...>)', function(assert) {
var input;
input = 'blah';
- test_minify_sync(assert, input, { removeRedundantAttributes: true }, 'blah');
+ test_minify(assert, input, 'blah', { removeRedundantAttributes: true });
input = '';
- test_minify_sync(assert, input, { removeRedundantAttributes: true }, input);
+ test_minify(assert, input, input, { removeRedundantAttributes: true });
input = 'blah';
- test_minify_sync(assert, input, { removeRedundantAttributes: true }, input);
+ test_minify(assert, input, input, { removeRedundantAttributes: true });
input = 'blah';
- test_minify_sync(assert, input, { removeRedundantAttributes: true }, 'blah');
+ test_minify(assert, input, 'blah', { removeRedundantAttributes: true });
});
QUnit.test('removing redundant attributes (<script src="..." charset="...">)', function(assert) {
@@ -1242,125 +1244,125 @@ QUnit.test('removing redundant attributes (<script src="..." charset="...">)'
input = '';
output = '';
- test_minify_sync(assert, input, { removeRedundantAttributes: true }, output);
+ test_minify(assert, input, output, { removeRedundantAttributes: true });
input = '';
- test_minify_sync(assert, input, { removeRedundantAttributes: true }, input);
+ test_minify(assert, input, input, { removeRedundantAttributes: true });
input = '';
output = '';
- test_minify_sync(assert, input, { removeRedundantAttributes: true }, output);
+ test_minify(assert, input, output, { removeRedundantAttributes: true });
});
QUnit.test('removing redundant attributes (<... language="javascript" ...>)', function(assert) {
var input;
input = '';
- test_minify_sync(assert, input, { removeRedundantAttributes: true }, '');
+ test_minify(assert, input, '', { removeRedundantAttributes: true });
input = '';
- test_minify_sync(assert, input, { removeRedundantAttributes: true }, '');
+ test_minify(assert, input, '', { removeRedundantAttributes: true });
});
QUnit.test('removing redundant attributes (<area shape="rect" ...>)', function(assert) {
var input = '';
var output = '';
- test_minify_sync(assert, input, { removeRedundantAttributes: true }, output);
+ test_minify(assert, input, output, { removeRedundantAttributes: true });
});
QUnit.test('removing redundant attributes (<... = "javascript: ..." ...>)', function(assert) {
var input;
input = 'x
';
- test_minify_sync(assert, input, 'x
');
+ test_minify(assert, input, 'x
');
input = 'x
';
- test_minify_sync(assert, input, { removeAttributeQuotes: true }, 'x
');
+ test_minify(assert, input, 'x
', { removeAttributeQuotes: true });
input = 'x
';
- test_minify_sync(assert, input, 'x
');
+ test_minify(assert, input, 'x
');
input = 'x
';
- test_minify_sync(assert, input, input);
+ test_minify(assert, input, input);
});
QUnit.test('removing javascript type attributes', function(assert) {
var input, output;
input = '';
- test_minify_sync(assert, input, { removeScriptTypeAttributes: false }, input);
+ test_minify(assert, input, input, { removeScriptTypeAttributes: false });
output = '';
- test_minify_sync(assert, input, { removeScriptTypeAttributes: true }, output);
+ test_minify(assert, input, output, { removeScriptTypeAttributes: true });
input = '';
- test_minify_sync(assert, input, { removeScriptTypeAttributes: false }, input);
+ test_minify(assert, input, input, { removeScriptTypeAttributes: false });
output = '';
- test_minify_sync(assert, input, { removeScriptTypeAttributes: true }, output);
+ test_minify(assert, input, output, { removeScriptTypeAttributes: true });
input = '';
output = '';
- test_minify_sync(assert, input, { removeScriptTypeAttributes: true }, output);
+ test_minify(assert, input, output, { removeScriptTypeAttributes: true });
input = '';
output = '';
- test_minify_sync(assert, input, { removeScriptTypeAttributes: true }, output);
+ test_minify(assert, input, output, { removeScriptTypeAttributes: true });
input = '';
output = '';
- test_minify_sync(assert, input, { removeScriptTypeAttributes: true }, output);
+ test_minify(assert, input, output, { removeScriptTypeAttributes: true });
});
QUnit.test('removing type="text/css" attributes', function(assert) {
var input, output;
input = '';
- test_minify_sync(assert, input, { removeStyleLinkTypeAttributes: false }, input);
+ test_minify(assert, input, input, { removeStyleLinkTypeAttributes: false });
output = '';
- test_minify_sync(assert, input, { removeStyleLinkTypeAttributes: true }, output);
+ test_minify(assert, input, output, { removeStyleLinkTypeAttributes: true });
input = '';
- test_minify_sync(assert, input, { removeStyleLinkTypeAttributes: false }, input);
+ test_minify(assert, input, input, { removeStyleLinkTypeAttributes: false });
output = '';
- test_minify_sync(assert, input, { removeStyleLinkTypeAttributes: true }, output);
+ test_minify(assert, input, output, { removeStyleLinkTypeAttributes: true });
input = '';
output = '';
- test_minify_sync(assert, input, { removeStyleLinkTypeAttributes: true }, output);
+ test_minify(assert, input, output, { removeStyleLinkTypeAttributes: true });
input = '';
- test_minify_sync(assert, input, { removeStyleLinkTypeAttributes: true }, input);
+ test_minify(assert, input, input, { removeStyleLinkTypeAttributes: true });
input = '';
output = '';
- test_minify_sync(assert, input, { removeStyleLinkTypeAttributes: true }, output);
+ test_minify(assert, input, output, { removeStyleLinkTypeAttributes: true });
input = '';
- test_minify_sync(assert, input, { removeStyleLinkTypeAttributes: true }, input);
+ test_minify(assert, input, input, { removeStyleLinkTypeAttributes: true });
});
QUnit.test('removing attribute quotes', function(assert) {
var input;
input = 'foo
';
- test_minify_sync(assert, input, { removeAttributeQuotes: true }, 'foo
');
+ test_minify(assert, input, 'foo
', { removeAttributeQuotes: true });
input = '';
- test_minify_sync(assert, input, { removeAttributeQuotes: true }, '');
+ test_minify(assert, input, '', { removeAttributeQuotes: true });
input = 'x';
- test_minify_sync(assert, input, { removeAttributeQuotes: true }, 'x');
+ test_minify(assert, input, 'x', { removeAttributeQuotes: true });
input = '\nfoo\n\n';
- test_minify_sync(assert, input, { removeAttributeQuotes: true }, '\nfoo\n\n');
+ test_minify(assert, input, '\nfoo\n\n', { removeAttributeQuotes: true });
input = '\nfoo\n\n';
- test_minify_sync(assert, input, { removeAttributeQuotes: true }, '\nfoo\n\n');
+ test_minify(assert, input, '\nfoo\n\n', { removeAttributeQuotes: true });
input = '\nfoo\n\n';
- test_minify_sync(assert, input, { removeAttributeQuotes: true, removeEmptyAttributes: true }, '\nfoo\n\n');
+ test_minify(assert, input, '\nfoo\n\n', { removeAttributeQuotes: true, removeEmptyAttributes: true });
input = '';
- test_minify_sync(assert, input, { removeAttributeQuotes: true }, '');
+ test_minify(assert, input, '', { removeAttributeQuotes: true });
});
QUnit.test('preserving custom attribute-wrapping markup', function(assert) {
@@ -1372,10 +1374,10 @@ QUnit.test('preserving custom attribute-wrapping markup', function(assert) {
};
input = '';
- test_minify_sync(assert, input, customAttrOptions, input);
+ test_minify(assert, input, input, customAttrOptions);
input = '';
- test_minify_sync(assert, input, customAttrOptions, input);
+ test_minify(assert, input, input, customAttrOptions);
// With multiple rules
customAttrOptions = {
@@ -1386,16 +1388,16 @@ QUnit.test('preserving custom attribute-wrapping markup', function(assert) {
};
input = '';
- test_minify_sync(assert, input, customAttrOptions, input);
+ test_minify(assert, input, input, customAttrOptions);
input = '';
- test_minify_sync(assert, input, customAttrOptions, input);
+ test_minify(assert, input, input, customAttrOptions);
input = '';
- test_minify_sync(assert, input, customAttrOptions, input);
+ test_minify(assert, input, input, customAttrOptions);
input = '';
- test_minify_sync(assert, input, customAttrOptions, input);
+ test_minify(assert, input, input, customAttrOptions);
// With multiple rules and richer options
customAttrOptions = {
@@ -1408,13 +1410,13 @@ QUnit.test('preserving custom attribute-wrapping markup', function(assert) {
};
input = '';
- test_minify_sync(assert, input, customAttrOptions, '');
+ test_minify(assert, input, '', customAttrOptions);
input = '';
- test_minify_sync(assert, input, customAttrOptions, '');
+ test_minify(assert, input, '', customAttrOptions);
customAttrOptions.keepClosingSlash = true;
- test_minify_sync(assert, input, customAttrOptions, '');
+ test_minify(assert, input, '', customAttrOptions);
});
QUnit.test('preserving custom attribute-joining markup', function(assert) {
@@ -1424,9 +1426,9 @@ QUnit.test('preserving custom attribute-joining markup', function(assert) {
customAttrAssign: [polymerConditionalAttributeJoin]
};
input = '';
- test_minify_sync(assert, input, customAttrOptions, input);
+ test_minify(assert, input, input, customAttrOptions);
input = '';
- test_minify_sync(assert, input, customAttrOptions, input);
+ test_minify(assert, input, input, customAttrOptions);
});
QUnit.test('collapsing whitespace', function(assert) {
@@ -1434,37 +1436,37 @@ QUnit.test('collapsing whitespace', function(assert) {
input = '';
output = '';
- test_minify_sync(assert, input, { collapseWhitespace: true }, output);
+ test_minify(assert, input, output, { collapseWhitespace: true });
input = 'foo
bar
\n\n \n\t\t baz
';
output = 'foo
bar
baz
';
- test_minify_sync(assert, input, { collapseWhitespace: true }, output);
+ test_minify(assert, input, output, { collapseWhitespace: true });
input = ' foo bar
';
output = 'foo bar
';
- test_minify_sync(assert, input, { collapseWhitespace: true }, output);
+ test_minify(assert, input, output, { collapseWhitespace: true });
input = 'foo\nbar
';
output = 'foo bar
';
- test_minify_sync(assert, input, { collapseWhitespace: true }, output);
+ test_minify(assert, input, output, { collapseWhitespace: true });
input = ' foo blah 22 bar ![]()
';
output = 'foo blah 22 bar ![]()
';
- test_minify_sync(assert, input, { collapseWhitespace: true }, output);
+ test_minify(assert, input, output, { collapseWhitespace: true });
input = '';
output = '';
- test_minify_sync(assert, input, { collapseWhitespace: true }, output);
+ test_minify(assert, input, output, { collapseWhitespace: true });
input = '
';
output = '';
- test_minify_sync(assert, input, { collapseWhitespace: true }, output);
+ test_minify(assert, input, output, { collapseWhitespace: true });
input = '';
output = '';
- test_minify_sync(assert, input, { collapseWhitespace: true }, output);
+ test_minify(assert, input, output, { collapseWhitespace: true });
output = '';
- test_minify_sync(assert, input, { collapseWhitespace: true, caseSensitive: true }, output);
+ test_minify(assert, input, output, { collapseWhitespace: true, caseSensitive: true });
input = '\r\n\r\n\r\n' +
'\r\n\r\n\r\n' +
@@ -1482,153 +1484,153 @@ QUnit.test('collapsing whitespace', function(assert) {
'' +
' \r\nxxxx
x Hello billy ' +
' ';
- test_minify_sync(assert, input, { collapseWhitespace: true }, output);
+ test_minify(assert, input, output, { collapseWhitespace: true });
input = ' hello world
';
output = ' hello world
';
- test_minify_sync(assert, input, { collapseWhitespace: true }, output);
+ test_minify(assert, input, output, { collapseWhitespace: true });
input = ' hello world
';
output = ' hello world
';
- test_minify_sync(assert, input, { collapseWhitespace: true }, output);
+ test_minify(assert, input, output, { collapseWhitespace: true });
input = '';
output = '';
- test_minify_sync(assert, input, { collapseWhitespace: true }, output);
+ test_minify(assert, input, output, { collapseWhitespace: true });
input = '';
output = '';
- test_minify_sync(assert, input, { collapseWhitespace: true }, output);
+ test_minify(assert, input, output, { collapseWhitespace: true });
});
QUnit.test('removing empty elements', function(assert) {
var input, output;
- test_minify_sync(assert, 'x
', { removeEmptyElements: true }, 'x
');
- test_minify_sync(assert, '', { removeEmptyElements: true }, '');
+ test_minify(assert, 'x
', 'x
', { removeEmptyElements: true });
+ test_minify(assert, '', '', { removeEmptyElements: true });
input = 'foobar
';
output = 'foobar
';
- test_minify_sync(assert, input, { removeEmptyElements: true }, output);
+ test_minify(assert, input, output, { removeEmptyElements: true });
input = '';
output = '';
- test_minify_sync(assert, input, { removeEmptyElements: true }, output);
+ test_minify(assert, input, output, { removeEmptyElements: true });
input = '';
output = '';
- test_minify_sync(assert, input, { removeEmptyElements: true }, output);
+ test_minify(assert, input, output, { removeEmptyElements: true });
input = '';
- test_minify_sync(assert, input, { removeEmptyElements: true }, input);
+ test_minify(assert, input, input, { removeEmptyElements: true });
input = '';
- test_minify_sync(assert, input, { removeEmptyElements: true }, input);
+ test_minify(assert, input, input, { removeEmptyElements: true });
input = '';
output = '';
- test_minify_sync(assert, input, { removeEmptyElements: true }, output);
+ test_minify(assert, input, output, { removeEmptyElements: true });
input = '';
- test_minify_sync(assert, input, { removeEmptyElements: true }, input);
+ test_minify(assert, input, input, { removeEmptyElements: true });
input = '';
output = '';
- test_minify_sync(assert, input, { removeEmptyElements: true }, output);
+ test_minify(assert, input, output, { removeEmptyElements: true });
input = '';
- test_minify_sync(assert, input, { removeEmptyElements: true }, input);
+ test_minify(assert, input, input, { removeEmptyElements: true });
input = '';
output = '';
- test_minify_sync(assert, input, { removeEmptyElements: true }, output);
+ test_minify(assert, input, output, { removeEmptyElements: true });
input = '';
- test_minify_sync(assert, input, { removeEmptyElements: true }, input);
+ test_minify(assert, input, input, { removeEmptyElements: true });
input = '';
output = '';
- test_minify_sync(assert, input, { removeEmptyElements: true }, output);
+ test_minify(assert, input, output, { removeEmptyElements: true });
input = '';
- test_minify_sync(assert, input, { removeEmptyElements: true }, input);
+ test_minify(assert, input, input, { removeEmptyElements: true });
input = '';
- test_minify_sync(assert, input, { removeEmptyElements: true }, input);
+ test_minify(assert, input, input, { removeEmptyElements: true });
input = 'helloworld
';
- test_minify_sync(assert, input, { removeEmptyElements: true }, input);
+ test_minify(assert, input, input, { removeEmptyElements: true });
input = 'x
';
output = 'x
';
- test_minify_sync(assert, input, { removeEmptyElements: true }, output);
+ test_minify(assert, input, output, { removeEmptyElements: true });
input = '';
output = '';
- test_minify_sync(assert, input, { removeEmptyElements: true }, output);
+ test_minify(assert, input, output, { removeEmptyElements: true });
input = '
';
- test_minify_sync(assert, input, { removeEmptyElements: true }, input);
+ test_minify(assert, input, input, { removeEmptyElements: true });
input = '';
output = '';
- test_minify_sync(assert, input, { removeEmptyElements: true }, output);
+ test_minify(assert, input, output, { removeEmptyElements: true });
input = '';
- test_minify_sync(assert, input, { removeEmptyElements: true }, input);
+ test_minify(assert, input, input, { removeEmptyElements: true });
input = '';
- test_minify_sync(assert, input, { removeEmptyElements: true }, '');
+ test_minify(assert, input, '', { removeEmptyElements: true });
input = 'after
';
output = 'after
';
- test_minify_sync(assert, input, { removeEmptyElements: true }, output);
+ test_minify(assert, input, output, { removeEmptyElements: true });
output = 'after
';
- test_minify_sync(assert, input, { collapseWhitespace: true, removeEmptyElements: true }, output);
+ test_minify(assert, input, output, { collapseWhitespace: true, removeEmptyElements: true });
input = 'before
';
output = 'before
';
- test_minify_sync(assert, input, { removeEmptyElements: true }, output);
+ test_minify(assert, input, output, { removeEmptyElements: true });
output = 'before
';
- test_minify_sync(assert, input, { collapseWhitespace: true, removeEmptyElements: true }, output);
+ test_minify(assert, input, output, { collapseWhitespace: true, removeEmptyElements: true });
input = 'both
';
output = 'both
';
- test_minify_sync(assert, input, { removeEmptyElements: true }, output);
+ test_minify(assert, input, output, { removeEmptyElements: true });
output = 'both
';
- test_minify_sync(assert, input, { collapseWhitespace: true, removeEmptyElements: true }, output);
+ test_minify(assert, input, output, { collapseWhitespace: true, removeEmptyElements: true });
input = 'unary
';
output = 'unary
';
- test_minify_sync(assert, input, { removeEmptyElements: true }, output);
+ test_minify(assert, input, output, { removeEmptyElements: true });
output = 'unary
';
- test_minify_sync(assert, input, { collapseWhitespace: true, removeEmptyElements: true }, output);
+ test_minify(assert, input, output, { collapseWhitespace: true, removeEmptyElements: true });
input = 'Empty
';
- test_minify_sync(assert, input, { removeEmptyElements: true }, input);
+ test_minify(assert, input, input, { removeEmptyElements: true });
output = 'Empty
';
- test_minify_sync(assert, input, { collapseWhitespace: true, removeEmptyElements: true }, output);
+ test_minify(assert, input, output, { collapseWhitespace: true, removeEmptyElements: true });
});
QUnit.test('collapsing boolean attributes', function(assert) {
var input, output;
input = '';
- test_minify_sync(assert, input, { collapseBooleanAttributes: true }, '');
+ test_minify(assert, input, '', { collapseBooleanAttributes: true });
input = '';
- test_minify_sync(assert, input, { collapseBooleanAttributes: true }, '');
+ test_minify(assert, input, '', { collapseBooleanAttributes: true });
input = '';
- test_minify_sync(assert, input, { collapseBooleanAttributes: true }, '');
+ test_minify(assert, input, '', { collapseBooleanAttributes: true });
input = '';
- test_minify_sync(assert, input, { collapseBooleanAttributes: true }, '');
+ test_minify(assert, input, '', { collapseBooleanAttributes: true });
input = '';
- test_minify_sync(assert, input, { collapseBooleanAttributes: true }, '');
+ test_minify(assert, input, '', { collapseBooleanAttributes: true });
input = '';
- test_minify_sync(assert, input, { collapseBooleanAttributes: true }, '');
+ test_minify(assert, input, '', { collapseBooleanAttributes: true });
input = '';
- test_minify_sync(assert, input, { collapseBooleanAttributes: true }, output);
+ test_minify(assert, input, output, { collapseBooleanAttributes: true });
output = '';
- test_minify_sync(assert, input, { collapseBooleanAttributes: true, caseSensitive: true }, output);
+ test_minify(assert, input, output, { collapseBooleanAttributes: true, caseSensitive: true });
});
QUnit.test('collapsing enumerated attributes', function(assert) {
- test_minify_sync(assert, '', { collapseBooleanAttributes: true }, '');
- test_minify_sync(assert, '', { collapseBooleanAttributes: true }, '');
- test_minify_sync(assert, '', { collapseBooleanAttributes: true }, '');
- test_minify_sync(assert, '', { collapseBooleanAttributes: true }, '');
- test_minify_sync(assert, '', { collapseBooleanAttributes: true }, '');
- test_minify_sync(assert, '', { collapseBooleanAttributes: true }, '');
- test_minify_sync(assert, '', { collapseBooleanAttributes: true }, '');
- test_minify_sync(assert, '', { collapseBooleanAttributes: true }, '');
- test_minify_sync(assert, '', { collapseBooleanAttributes: true }, '');
- test_minify_sync(assert, '', { collapseBooleanAttributes: true }, '');
- test_minify_sync(assert, '', { collapseBooleanAttributes: true }, '');
+ test_minify(assert, '', '', { collapseBooleanAttributes: true });
+ test_minify(assert, '', '', { collapseBooleanAttributes: true });
+ test_minify(assert, '', '', { collapseBooleanAttributes: true });
+ test_minify(assert, '', '', { collapseBooleanAttributes: true });
+ test_minify(assert, '', '', { collapseBooleanAttributes: true });
+ test_minify(assert, '', '', { collapseBooleanAttributes: true });
+ test_minify(assert, '', '', { collapseBooleanAttributes: true });
+ test_minify(assert, '', '', { collapseBooleanAttributes: true });
+ test_minify(assert, '', '', { collapseBooleanAttributes: true });
+ test_minify(assert, '', '', { collapseBooleanAttributes: true });
+ test_minify(assert, '', '', { collapseBooleanAttributes: true });
});
QUnit.test('keeping trailing slashes in tags', function(assert) {
- test_minify_sync(assert, '
', { keepClosingSlash: true }, '
');
+ test_minify(assert, '
', '
', { keepClosingSlash: true });
// https://github.com/kangax/html-minifier/issues/233
- test_minify_sync(assert, '
', { keepClosingSlash: true, removeAttributeQuotes: true }, '
');
- test_minify_sync(assert, '
', { keepClosingSlash: true, removeAttributeQuotes: true, removeEmptyAttributes: true }, '
');
- test_minify_sync(assert, '
', { keepClosingSlash: true, removeAttributeQuotes: true }, '
');
+ test_minify(assert, '
', '
', { keepClosingSlash: true, removeAttributeQuotes: true });
+ test_minify(assert, '
', '
', { keepClosingSlash: true, removeAttributeQuotes: true, removeEmptyAttributes: true });
+ test_minify(assert, '
', '
', { keepClosingSlash: true, removeAttributeQuotes: true });
});
QUnit.test('removing optional tags', function(assert) {
var input, output;
input = 'foo';
- test_minify_sync(assert, input, { removeOptionalTags: true }, input);
+ test_minify(assert, input, input, { removeOptionalTags: true });
input = '
';
output = '';
- test_minify_sync(assert, input, { removeOptionalTags: true }, output);
+ test_minify(assert, input, output, { removeOptionalTags: true });
input = '
';
output = '';
- test_minify_sync(assert, input, { removeOptionalTags: true }, output);
- test_minify_sync(assert, input, { removeOptionalTags: true, removeEmptyElements: true }, output);
+ test_minify(assert, input, output, { removeOptionalTags: true });
+ test_minify(assert, input, output, { removeOptionalTags: true, removeEmptyElements: true });
input = '';
output = '';
- test_minify_sync(assert, input, { removeOptionalTags: true }, output);
- test_minify_sync(assert, input, { removeOptionalTags: true, removeEmptyElements: true }, output);
+ test_minify(assert, input, output, { removeOptionalTags: true });
+ test_minify(assert, input, output, { removeOptionalTags: true, removeEmptyElements: true });
input = ' ';
output = ' ';
- test_minify_sync(assert, input, { removeOptionalTags: true }, output);
+ test_minify(assert, input, output, { removeOptionalTags: true });
output = '';
- test_minify_sync(assert, input, { collapseWhitespace: true, removeOptionalTags: true }, output);
+ test_minify(assert, input, output, { collapseWhitespace: true, removeOptionalTags: true });
input = ' ';
output = ' ';
- test_minify_sync(assert, input, { removeOptionalTags: true }, output);
+ test_minify(assert, input, output, { removeOptionalTags: true });
output = '';
- test_minify_sync(assert, input, { collapseWhitespace: true, removeOptionalTags: true }, output);
+ test_minify(assert, input, output, { collapseWhitespace: true, removeOptionalTags: true });
input = ' ';
output = ' ';
- test_minify_sync(assert, input, { removeOptionalTags: true }, output);
+ test_minify(assert, input, output, { removeOptionalTags: true });
output = '';
- test_minify_sync(assert, input, { collapseWhitespace: true, removeOptionalTags: true }, output);
+ test_minify(assert, input, output, { collapseWhitespace: true, removeOptionalTags: true });
input = ' ';
output = ' ';
- test_minify_sync(assert, input, { removeOptionalTags: true }, output);
+ test_minify(assert, input, output, { removeOptionalTags: true });
output = '';
- test_minify_sync(assert, input, { collapseWhitespace: true, removeOptionalTags: true }, output);
+ test_minify(assert, input, output, { collapseWhitespace: true, removeOptionalTags: true });
input = ' ';
output = ' ';
- test_minify_sync(assert, input, { removeOptionalTags: true }, output);
+ test_minify(assert, input, output, { removeOptionalTags: true });
output = '';
- test_minify_sync(assert, input, { collapseWhitespace: true, removeOptionalTags: true }, output);
+ test_minify(assert, input, output, { collapseWhitespace: true, removeOptionalTags: true });
input = ' ';
output = ' ';
- test_minify_sync(assert, input, { removeOptionalTags: true }, output);
+ test_minify(assert, input, output, { removeOptionalTags: true });
output = '';
- test_minify_sync(assert, input, { collapseWhitespace: true, removeOptionalTags: true }, output);
+ test_minify(assert, input, output, { collapseWhitespace: true, removeOptionalTags: true });
input = ' ';
output = ' ';
- test_minify_sync(assert, input, { removeOptionalTags: true }, output);
+ test_minify(assert, input, output, { removeOptionalTags: true });
output = '';
- test_minify_sync(assert, input, { collapseWhitespace: true, removeOptionalTags: true }, output);
+ test_minify(assert, input, output, { collapseWhitespace: true, removeOptionalTags: true });
input = ' ';
output = ' ';
- test_minify_sync(assert, input, { removeOptionalTags: true }, output);
+ test_minify(assert, input, output, { removeOptionalTags: true });
output = '';
- test_minify_sync(assert, input, { collapseWhitespace: true, removeOptionalTags: true }, output);
+ test_minify(assert, input, output, { collapseWhitespace: true, removeOptionalTags: true });
input = 'hellofoobar
';
- test_minify_sync(assert, input, input);
+ test_minify(assert, input, input);
output = 'hellofoobar';
- test_minify_sync(assert, input, { removeOptionalTags: true }, output);
+ test_minify(assert, input, output, { removeOptionalTags: true });
input = '
hellofoobar
';
output = 'hellofoobar';
- test_minify_sync(assert, input, { removeOptionalTags: true }, output);
+ test_minify(assert, input, output, { removeOptionalTags: true });
output = '
hellofoobar';
- test_minify_sync(assert, input, { removeOptionalTags: true, removeEmptyAttributes: true }, output);
+ test_minify(assert, input, output, { removeOptionalTags: true, removeEmptyAttributes: true });
input = '
a';
output = 'a';
- test_minify_sync(assert, input, { removeOptionalTags: true }, output);
+ test_minify(assert, input, output, { removeOptionalTags: true });
input = 'BlahThis is some text in a div
Followed by some details This is some more text in a div
';
output = 'BlahThis is some text in a divFollowed by some details
This is some more text in a div
';
- test_minify_sync(assert, input, { removeOptionalTags: true }, output);
+ test_minify(assert, input, output, { removeOptionalTags: true });
input = 'Blah';
output = 'Blah';
- test_minify_sync(assert, input, { removeOptionalTags: true }, output);
+ test_minify(assert, input, output, { removeOptionalTags: true });
input = 'Configure
';
- test_minify_sync(assert, input, { removeOptionalTags: true }, input);
+ test_minify(assert, input, input, { removeOptionalTags: true });
});
QUnit.test('removing optional tags in tables', function(assert) {
@@ -1773,22 +1775,22 @@ QUnit.test('removing optional tags in tables', function(assert) {
'boo | moo | loo |
' +
'baz | qux | boo |
' +
'';
- test_minify_sync(assert, input, input);
+ test_minify(assert, input, input);
output = '' +
'foo | bar | baz |
' +
'boo | moo | loo |
' +
'baz | qux | boo' +
' |
---|
';
- test_minify_sync(assert, input, { removeOptionalTags: true }, output);
+ test_minify(assert, input, output, { removeOptionalTags: true });
output = '' +
'foo | bar | baz' +
' |
---|
boo | moo | loo' +
' |
baz | qux | boo' +
' |
---|
';
- test_minify_sync(assert, input, { collapseWhitespace: true, removeOptionalTags: true }, output);
- test_minify_sync(assert, output, { collapseWhitespace: true, removeOptionalTags: true }, output);
+ test_minify(assert, input, output, { collapseWhitespace: true, removeOptionalTags: true });
+ test_minify(assert, output, output, { collapseWhitespace: true, removeOptionalTags: true });
input = '' +
'foo' +
@@ -1797,7 +1799,7 @@ QUnit.test('removing optional tags in tables', function(assert) {
'' +
'bar | baz | qux |
' +
'
';
- test_minify_sync(assert, input, input);
+ test_minify(assert, input, input);
output = '' +
'foo' +
@@ -1806,23 +1808,23 @@ QUnit.test('removing optional tags in tables', function(assert) {
'' +
'bar | baz | qux' +
' |
---|
';
- test_minify_sync(assert, input, { removeOptionalTags: true }, output);
- test_minify_sync(assert, output, { removeOptionalTags: true }, output);
+ test_minify(assert, input, output, { removeOptionalTags: true });
+ test_minify(assert, output, output, { removeOptionalTags: true });
output = '' +
'foo' +
'' +
'bar | baz | qux' +
' |
---|
';
- test_minify_sync(assert, input, { removeComments: true, removeOptionalTags: true }, output);
+ test_minify(assert, input, output, { removeComments: true, removeOptionalTags: true });
input = '';
- test_minify_sync(assert, input, input);
+ test_minify(assert, input, input);
output = '';
- test_minify_sync(assert, input, { removeOptionalTags: true }, output);
+ test_minify(assert, input, output, { removeOptionalTags: true });
});
QUnit.test('removing optional tags in options', function(assert) {
@@ -1830,17 +1832,17 @@ QUnit.test('removing optional tags in options', function(assert) {
input = '';
output = '';
- test_minify_sync(assert, input, { removeOptionalTags: true }, output);
+ test_minify(assert, input, output, { removeOptionalTags: true });
input = '';
- test_minify_sync(assert, input, { removeOptionalTags: true }, input);
+ test_minify(assert, input, input, { removeOptionalTags: true });
output = '';
- test_minify_sync(assert, input, { removeOptionalTags: true, collapseWhitespace: true }, output);
+ test_minify(assert, input, output, { removeOptionalTags: true, collapseWhitespace: true });
output = '';
- test_minify_sync(assert, input, { removeOptionalTags: true, collapseWhitespace: true, conservativeCollapse: true }, output);
+ test_minify(assert, input, output, { removeOptionalTags: true, collapseWhitespace: true, conservativeCollapse: true });
// example from htmldog.com
input = '';
- test_minify_sync(assert, input, { removeOptionalTags: true }, output);
+ test_minify(assert, input, output, { removeOptionalTags: true });
});
QUnit.test('custom components', function(assert) {
var input = 'Oh, my.';
var output = 'Oh, my.';
- test_minify_sync(assert, input, output);
+ test_minify(assert, input, output);
});
QUnit.test('HTML4: anchor with inline elements', function(assert) {
var input = 'Well, look at me! I\'m a span!';
- test_minify_sync(assert, input, { html5: false }, input);
+ test_minify(assert, input, input, { html5: false });
});
QUnit.test('HTML5: anchor with inline elements', function(assert) {
var input = 'Well, look at me! I\'m a span!';
- test_minify_sync(assert, input, { html5: true }, input);
+ test_minify(assert, input, input, { html5: true });
});
QUnit.test('HTML4: anchor with block elements', function(assert) {
var input = 'Well, look at me! I\'m a div!
';
var output = 'Well, look at me! I\'m a div!
';
- test_minify_sync(assert, input, { html5: false }, output);
+ test_minify(assert, input, output, { html5: false });
});
QUnit.test('HTML5: anchor with block elements', function(assert) {
var input = 'Well, look at me! I\'m a div!
';
var output = 'Well, look at me! I\'m a div!
';
- test_minify_sync(assert, input, { html5: true }, output);
+ test_minify(assert, input, output, { html5: true });
});
QUnit.test('HTML5: enabled by default', function(assert) {
var input = 'Well, look at me! I\'m a div!
';
- test_minify_sync(assert, input, { html5: true }, minify(input));
+ test_minify(assert, input, minify(input), { html5: true });
});
QUnit.test('phrasing content', function(assert) {
@@ -1900,12 +1902,12 @@ QUnit.test('phrasing content', function(assert) {
input = 'a
b
';
output = 'a
b
';
- test_minify_sync(assert, input, { html5: true }, output);
+ test_minify(assert, input, output, { html5: true });
output = 'a
b
';
- test_minify_sync(assert, input, { html5: false }, output);
+ test_minify(assert, input, output, { html5: false });
input = '';
- test_minify_sync(assert, input, { html5: true }, input);
+ test_minify(assert, input, input, { html5: true });
});
// https://github.com/kangax/html-minifier/issues/888
@@ -1914,29 +1916,29 @@ QUnit.test('ul/ol should be phrasing content', function(assert) {
input = 'a
';
output = 'a
';
- test_minify_sync(assert, input, { html5: true }, output);
+ test_minify(assert, input, output, { html5: true });
output = 'a
';
- test_minify_sync(assert, input, { html5: true, removeOptionalTags: true }, output);
+ test_minify(assert, input, output, { html5: true, removeOptionalTags: true });
output = 'a
';
- test_minify_sync(assert, input, { html5: false }, output);
+ test_minify(assert, input, output, { html5: false });
input = 'a
- item
';
output = 'a
- item
';
- test_minify_sync(assert, input, { html5: true }, output);
+ test_minify(assert, input, output, { html5: true });
output = 'a
- item
';
- test_minify_sync(assert, input, { html5: true, removeOptionalTags: true }, output);
+ test_minify(assert, input, output, { html5: true, removeOptionalTags: true });
output = '
a
- item
';
- test_minify_sync(assert, input, { html5: true, removeEmptyElements: true }, output);
+ test_minify(assert, input, output, { html5: true, removeEmptyElements: true });
});
QUnit.test('phrasing content with Web Components', function(assert) {
var input = '';
var output = '';
- test_minify_sync(assert, input, { html5: true }, output);
+ test_minify(assert, input, output, { html5: true });
});
// https://github.com/kangax/html-minifier/issues/10
@@ -1946,52 +1948,52 @@ QUnit.test('Ignore custom fragments', function(assert) {
input = 'This is the start. <% ... %>\r\n<%= ... %>\r\n ... ?>\r\n\r\nNo comment, but middle.\r\n{{ ... }}\r\n\r\n\r\nHello, this is the end!';
output = 'This is the start. <% ... %> <%= ... %> ... ?> No comment, but middle. {{ ... }} Hello, this is the end!';
- test_minify_sync(assert, input, {}, input);
- test_minify_sync(assert, input, { removeComments: true, collapseWhitespace: true }, output);
- test_minify_sync(assert, input, {
+ test_minify(assert, input, input, {});
+ test_minify(assert, input, output, { removeComments: true, collapseWhitespace: true });
+ test_minify(assert, input, output, {
removeComments: true,
collapseWhitespace: true,
ignoreCustomFragments: reFragments
- }, output);
+ });
output = 'This is the start. <% ... %>\n<%= ... %>\n ... ?>\nNo comment, but middle. {{ ... }}\n\n\nHello, this is the end!';
- test_minify_sync(assert, input, {
+ test_minify(assert, input, output, {
removeComments: true,
collapseWhitespace: true,
preserveLineBreaks: true
- }, output);
+ });
output = 'This is the start. <% ... %>\n<%= ... %>\n ... ?>\nNo comment, but middle.\n{{ ... }}\n\n\nHello, this is the end!';
- test_minify_sync(assert, input, {
+ test_minify(assert, input, output, {
removeComments: true,
collapseWhitespace: true,
preserveLineBreaks: true,
ignoreCustomFragments: reFragments
- }, output);
+ });
input = '{{ if foo? }}\r\n \r\n ...\r\n
\r\n{{ end \n}}';
output = '{{ if foo? }}...
{{ end }}';
- test_minify_sync(assert, input, {}, input);
- test_minify_sync(assert, input, { collapseWhitespace: true }, output);
- test_minify_sync(assert, input, { collapseWhitespace: true, ignoreCustomFragments: [] }, output);
+ test_minify(assert, input, input, {});
+ test_minify(assert, input, output, { collapseWhitespace: true });
+ test_minify(assert, input, output, { collapseWhitespace: true, ignoreCustomFragments: [] });
output = '{{ if foo? }} ...
{{ end \n}}';
- test_minify_sync(assert, input, { collapseWhitespace: true, ignoreCustomFragments: reFragments }, output);
+ test_minify(assert, input, output, { collapseWhitespace: true, ignoreCustomFragments: reFragments });
output = '{{ if foo? }}\n\n...\n
\n{{ end \n}}';
- test_minify_sync(assert, input, {
+ test_minify(assert, input, output, {
collapseWhitespace: true,
preserveLineBreaks: true,
ignoreCustomFragments: reFragments
- }, output);
+ });
input = '';
- test_minify_sync(assert, input, {}, input);
- test_minify_sync(assert, input, { ignoreCustomFragments: reFragments }, input);
+ test_minify(assert, input, input, {});
+ test_minify(assert, input, input, { ignoreCustomFragments: reFragments });
input = '
';
output = '
';
- test_minify_sync(assert, input, { ignoreCustomFragments: [/\{%[^%]*?%\}/g] }, output);
+ test_minify(assert, input, output, { ignoreCustomFragments: [/\{%[^%]*?%\}/g] });
input = '' +
'{{ form.name.label_tag }}' +
@@ -2003,13 +2005,13 @@ QUnit.test('Ignore custom fragments', function(assert) {
'{% endfor %}' +
'{% endif %}' +
'
';
- test_minify_sync(assert, input, {
+ test_minify(assert, input, input, {
ignoreCustomFragments: [
/\{%[\s\S]*?%\}/g,
/\{\{[\s\S]*?\}\}/g
],
quoteCharacter: '\''
- }, input);
+ });
output = '' +
'{{ form.name.label_tag }}' +
'{{ form.name }}' +
@@ -2020,151 +2022,151 @@ QUnit.test('Ignore custom fragments', function(assert) {
'{% endfor %}' +
'{% endif %}' +
'
';
- test_minify_sync(assert, input, {
+ test_minify(assert, input, output, {
ignoreCustomFragments: [
/\{%[\s\S]*?%\}/g,
/\{\{[\s\S]*?\}\}/g
],
quoteCharacter: '\'',
collapseWhitespace: true
- }, output);
+ });
input = '>Legal Notices';
- test_minify_sync(assert, input, {
+ test_minify(assert, input, input, {
ignoreCustomFragments: [
/<\?php[\s\S]*?\?>/g
]
- }, input);
+ });
input = '>';
- test_minify_sync(assert, input, {
+ test_minify(assert, input, input, {
ignoreCustomFragments: [
/<%=[\s\S]*?%>/g
]
- }, input);
+ });
input = '';
- test_minify_sync(assert, input, {
+ test_minify(assert, input, input, {
ignoreCustomFragments: [
/\{\{[\s\S]*?\}\}/g
],
caseSensitive: true
- }, input);
+ });
input = '
';
- test_minify_sync(assert, input, {
+ test_minify(assert, input, input, {
ignoreCustomFragments: [
/\{%[^%]*?%\}/g
]
- }, input);
+ });
// trimCustomFragments withOUT collapseWhitespace, does
// not break the "{% foo %} {% bar %}" test
- test_minify_sync(assert, input, {
+ test_minify(assert, input, input, {
ignoreCustomFragments: [
/\{%[^%]*?%\}/g
],
trimCustomFragments: true
- }, input);
+ });
// trimCustomFragments WITH collapseWhitespace, changes output
output = '
';
- test_minify_sync(assert, input, {
+ test_minify(assert, input, output, {
ignoreCustomFragments: [
/\{%[^%]*?%\}/g
],
collapseWhitespace: true,
trimCustomFragments: true
- }, output);
+ });
input = '
';
- test_minify_sync(assert, input, input);
- test_minify_sync(assert, input, {
+ test_minify(assert, input, input);
+ test_minify(assert, input, input, {
collapseWhitespace: true
- }, input);
+ });
input = '';
- test_minify_sync(assert, input, input);
- test_minify_sync(assert, input, {
+ test_minify(assert, input, input);
+ test_minify(assert, input, input, {
collapseWhitespace: true
- }, input);
+ });
input = '{{if a}}b
{{/if}}';
- test_minify_sync(assert, input, input);
+ test_minify(assert, input, input);
output = '{{if a}}b
{{/if}}';
- test_minify_sync(assert, input, {
+ test_minify(assert, input, output, {
removeComments: true,
ignoreCustomFragments: [
/\{\{.*?\}\}/g
]
- }, output);
+ });
// https://github.com/kangax/html-minifier/issues/722
input = ' echo "foo"; ?> bar';
- test_minify_sync(assert, input, input);
- test_minify_sync(assert, input, {
+ test_minify(assert, input, input);
+ test_minify(assert, input, input, {
collapseWhitespace: true
- }, input);
+ });
output = ' echo "foo"; ?>bar';
- test_minify_sync(assert, input, {
+ test_minify(assert, input, output, {
collapseWhitespace: true,
trimCustomFragments: true
- }, output);
+ });
input = ' echo "foo"; ?> bar';
- test_minify_sync(assert, input, input);
+ test_minify(assert, input, input);
output = ' echo "foo"; ?> bar';
- test_minify_sync(assert, input, {
+ test_minify(assert, input, output, {
collapseWhitespace: true
- }, output);
+ });
output = ' echo "foo"; ?>bar';
- test_minify_sync(assert, input, {
+ test_minify(assert, input, output, {
collapseWhitespace: true,
trimCustomFragments: true
- }, output);
+ });
input = 'foo echo "bar"; ?> baz';
- test_minify_sync(assert, input, input);
- test_minify_sync(assert, input, {
+ test_minify(assert, input, input);
+ test_minify(assert, input, input, {
collapseWhitespace: true
- }, input);
+ });
output = 'foo echo "bar"; ?>baz';
- test_minify_sync(assert, input, {
+ test_minify(assert, input, output, {
collapseWhitespace: true,
trimCustomFragments: true
- }, output);
+ });
input = 'foo echo "bar"; ?> echo "baz"; ?> foo';
- test_minify_sync(assert, input, input);
- test_minify_sync(assert, input, {
+ test_minify(assert, input, input);
+ test_minify(assert, input, input, {
collapseWhitespace: true
- }, input);
+ });
output = 'foo echo "bar"; ?> echo "baz"; ?>foo';
- test_minify_sync(assert, input, {
+ test_minify(assert, input, output, {
collapseWhitespace: true,
trimCustomFragments: true
- }, output);
+ });
input = 'foo baz moo loo';
- test_minify_sync(assert, input, {
+ test_minify(assert, input, input, {
collapseWhitespace: true,
ignoreCustomFragments: [
/<(WC@[\s\S]*?)>(.*?)<\/\1>/
]
- }, input);
+ });
output = 'foobaz mooloo';
- test_minify_sync(assert, input, {
+ test_minify(assert, input, output, {
collapseWhitespace: true
- }, output);
+ });
input = '';
- test_minify_sync(assert, input, input);
- test_minify_sync(assert, input, { removeAttributeQuotes: true }, input);
+ test_minify(assert, input, input);
+ test_minify(assert, input, input, { removeAttributeQuotes: true });
input = '\nfoo\n bar ?>\nbaz\n
';
- test_minify_sync(assert, input, input);
- test_minify_sync(assert, input, { collapseWhitespace: true }, input);
+ test_minify(assert, input, input);
+ test_minify(assert, input, input, { collapseWhitespace: true });
});
QUnit.test('bootstrap\'s span > button > span', function(assert) {
@@ -2174,15 +2176,15 @@ QUnit.test('bootstrap\'s span > button > span', function(assert) {
'\n ' +
'';
var output = '';
- test_minify_sync(assert, input, { collapseWhitespace: true, removeAttributeQuotes: true }, output);
+ test_minify(assert, input, output, { collapseWhitespace: true, removeAttributeQuotes: true });
});
QUnit.test('caseSensitive', function(assert) {
var input = '';
var caseSensitiveOutput = '';
var caseInSensitiveOutput = '';
- test_minify_sync(assert, input, caseInSensitiveOutput);
- test_minify_sync(assert, input, { caseSensitive: true }, caseSensitiveOutput);
+ test_minify(assert, input, caseInSensitiveOutput);
+ test_minify(assert, input, caseSensitiveOutput, { caseSensitive: true });
});
QUnit.test('source & track', function(assert) {
@@ -2192,8 +2194,8 @@ QUnit.test('source & track', function(assert) {
'' +
'