},
"extends": "eslint:recommended",
"rules": {
- "array-bracket-spacing": [
- "error",
- "always"
- ],
+ "array-bracket-spacing": "error",
"block-scoped-var": "error",
"block-spacing": "error",
"brace-style": [
src: 'Gruntfile.js'
},
src: {
- src: [ 'cli.js', 'src/**/*.js' ]
+ src: ['cli.js', 'src/**/*.js']
},
tests: {
- src: [ 'tests/*.js', 'test.js' ]
+ src: ['tests/*.js', 'test.js']
},
web: {
src: 'assets/master.js'
},
other: {
- src: [ 'backtest.js', 'benchmark.js' ]
+ src: ['backtest.js', 'benchmark.js']
}
},
});
require('load-grunt-tasks')(grunt, {
- pattern: [ 'grunt-*', '!grunt-lib-*' ],
+ pattern: ['grunt-*', '!grunt-lib-*'],
scope: 'devDependencies'
});
require('time-grunt')(grunt);
function git() {
var args = [].concat.apply([], [].slice.call(arguments, 0, -1));
var callback = arguments[arguments.length - 1];
- var task = child_process.spawn('git', args, { stdio: [ 'ignore', 'pipe', 'ignore' ] });
+ var task = child_process.spawn('git', args, { stdio: ['ignore', 'pipe', 'ignore'] });
var output = '';
task.stdout.setEncoding('utf8');
task.stdout.on('data', function(data) {
output.push(row.join(','));
for (var hash in table) {
var data = table[hash];
- row = [ hash, '"' + data.date + '"' ];
+ row = [hash, '"' + data.date + '"'];
fileNames.forEach(function(fileName) {
row.push(data[fileName]);
});
}
else {
process.on('message', function(hash) {
- var paths = [ 'src', 'benchmark.conf', 'sample-cli-config-file.conf' ];
+ var paths = ['src', 'benchmark.conf', 'sample-cli-config-file.conf'];
git('reset', 'HEAD', '--', paths, function() {
var conf = 'sample-cli-config-file.conf';
});
var table = new Table({
- head: [ 'File', 'Before', 'After', 'Minimize', 'Will Peavy', 'htmlcompressor.com', 'Savings', 'Time' ],
- colWidths: [ 20, 25, 25, 25, 25, 25, 20, 10 ]
+ head: ['File', 'Before', 'After', 'Minimize', 'Will Peavy', 'htmlcompressor.com', 'Savings', 'Time'],
+ colWidths: [20, 25, 25, 25, 25, 25, 20, 10]
});
function toKb(size) {
brFilePath: path.join('benchmarks/generated/', fileName + '.html.br')
};
var infos = {};
- [ 'minifier', 'minimize', 'willpeavy', 'compressor' ].forEach(function (name) {
+ ['minifier', 'minimize', 'willpeavy', 'compressor'].forEach(function (name) {
infos[name] = {
filePath: path.join('benchmarks/generated/', fileName + '.' + name + '.html'),
gzFilePath: path.join('benchmarks/generated/', fileName + '.' + name + '.html.gz'),
function testHTMLMinifier(done) {
var info = infos.minifier;
info.startTime = Date.now();
- var args = [ filePath, '-c', 'sample-cli-config-file.conf', '--minify-urls', urls[fileName], '-o', info.filePath ];
+ var args = [filePath, '-c', 'sample-cli-config-file.conf', '--minify-urls', urls[fileName], '-o', info.filePath];
fork('./cli', args).on('exit', function () {
readSizes(info, done);
});
testHTMLCompressor
], function () {
var row = [
- [ fileName, '+ gzip', '+ lzma', '+ brotli' ].join('\n'),
- [ redSize(original.size), redSize(original.gzSize), redSize(original.lzSize), redSize(original.brSize) ].join('\n')
+ [fileName, '+ gzip', '+ lzma', '+ brotli'].join('\n'),
+ [redSize(original.size), redSize(original.gzSize), redSize(original.lzSize), redSize(original.brSize)].join('\n')
];
for (var name in infos) {
var info = infos[name];
- row.push([ greenSize(info.size), greenSize(info.gzSize), greenSize(info.lzSize), greenSize(info.brSize) ].join('\n'));
+ row.push([greenSize(info.size), greenSize(info.gzSize), greenSize(info.lzSize), greenSize(info.brSize)].join('\n'));
}
row.push(
[
cli.setUsage(usage);
var mainOptions = {
- caseSensitive: [ [ false, 'Treat attributes in case sensitive manner (useful for SVG; e.g. viewBox)' ] ],
- collapseBooleanAttributes: [ [ false, 'Omit attribute values from boolean attributes' ] ],
- collapseInlineTagWhitespace: [ [ false, 'Collapse white space around inline tag' ] ],
- collapseWhitespace: [ [ false, 'Collapse white space that contributes to text nodes in a document tree.' ] ],
- conservativeCollapse: [ [ false, 'Always collapse to 1 space (never remove it entirely)' ] ],
- customAttrAssign: [ [ false, 'Arrays of regex\'es that allow to support custom attribute assign expressions (e.g. \'<div flex?="{{mode != cover}}"></div>\')', 'string' ], 'json-regex' ],
- customAttrCollapse: [ [ false, 'Regex that specifies custom attribute to strip newlines from (e.g. /ng\-class/)', 'string' ], 'string-regex' ],
- customAttrSurround: [ [ false, 'Arrays of regex\'es that allow to support custom attribute surround expressions (e.g. <input {{#if value}}checked="checked"{{/if}}>)', 'string' ], 'json-regex' ],
- customEventAttributes: [ [ false, 'Arrays of regex\'es that allow to support custom event attributes for minifyJS (e.g. ng-click)', 'string' ], 'json-regex' ],
- html5: [ [ false, 'Parse input according to HTML5 specifications' ] ],
- ignoreCustomComments: [ [ false, 'Array of regex\'es that allow to ignore certain comments, when matched', 'string' ], 'json-regex' ],
- ignoreCustomFragments: [ [ false, 'Array of regex\'es that allow to ignore certain fragments, when matched (e.g. <?php ... ?>, {{ ... }})', 'string' ], 'json-regex' ],
- includeAutoGeneratedTags: [ [ false, 'Insert tags generated by HTML parser' ], true ],
- keepClosingSlash: [ [ false, 'Keep the trailing slash on singleton elements' ] ],
- lint: [ [ false, 'Toggle linting' ] ],
- maxLineLength: [ [ false, 'Max line length', 'number' ], true ],
- minifyCSS: [ [ false, 'Minify CSS in style elements and style attributes (uses clean-css)' ] ],
- minifyJS: [ [ false, 'Minify Javascript in script elements and on* attributes (uses UglifyJS)' ] ],
- minifyURLs: [ [ false, 'Minify URLs in various attributes (uses relateurl)', 'string' ], 'site-url' ],
- preserveLineBreaks: [ [ false, 'Always collapse to 1 line break (never remove it entirely) when whitespace between tags include a line break.' ] ],
- preventAttributesEscaping: [ [ false, 'Prevents the escaping of the values of attributes.' ] ],
- processConditionalComments: [ [ false, 'Process contents of conditional comments through minifier' ] ],
- processScripts: [ [ false, 'Array of strings corresponding to types of script elements to process through minifier (e.g. "text/ng-template", "text/x-handlebars-template", etc.)', 'string' ], 'json' ],
- quoteCharacter: [ [ false, 'Type of quote to use for attribute values (\' or ")', 'string' ], true ],
- removeAttributeQuotes: [ [ false, 'Remove quotes around attributes when possible.' ] ],
- removeComments: [ [ false, 'Strip HTML comments' ] ],
- removeEmptyAttributes: [ [ false, 'Remove all attributes with whitespace-only values' ] ],
- removeEmptyElements: [ [ false, 'Remove all elements with empty contents' ] ],
- removeOptionalTags: [ [ false, 'Remove unrequired tags' ] ],
- removeRedundantAttributes: [ [ false, 'Remove attributes when value matches default.' ] ],
- removeScriptTypeAttributes: [ [ false, 'Remove type="text/javascript" from script tags. Other type attribute values are left intact.' ] ],
- removeStyleLinkTypeAttributes: [ [ false, 'Remove type="text/css" from style and link tags. Other type attribute values are left intact.' ] ],
- removeTagWhitespace: [ [ false, 'Remove space between attributes whenever possible' ] ],
- sortAttributes: [ [ false, 'Sort attributes by frequency' ] ],
- useShortDoctype: [ [ false, 'Replaces the doctype with the short (HTML5) doctype' ] ]
+ caseSensitive: [[false, 'Treat attributes in case sensitive manner (useful for SVG; e.g. viewBox)']],
+ collapseBooleanAttributes: [[false, 'Omit attribute values from boolean attributes']],
+ collapseInlineTagWhitespace: [[false, 'Collapse white space around inline tag']],
+ collapseWhitespace: [[false, 'Collapse white space that contributes to text nodes in a document tree.']],
+ conservativeCollapse: [[false, 'Always collapse to 1 space (never remove it entirely)']],
+ customAttrAssign: [[false, 'Arrays of regex\'es that allow to support custom attribute assign expressions (e.g. \'<div flex?="{{mode != cover}}"></div>\')', 'string'], 'json-regex'],
+ customAttrCollapse: [[false, 'Regex that specifies custom attribute to strip newlines from (e.g. /ng\-class/)', 'string'], 'string-regex'],
+ customAttrSurround: [[false, 'Arrays of regex\'es that allow to support custom attribute surround expressions (e.g. <input {{#if value}}checked="checked"{{/if}}>)', 'string'], 'json-regex'],
+ customEventAttributes: [[false, 'Arrays of regex\'es that allow to support custom event attributes for minifyJS (e.g. ng-click)', 'string'], 'json-regex'],
+ html5: [[false, 'Parse input according to HTML5 specifications']],
+ ignoreCustomComments: [[false, 'Array of regex\'es that allow to ignore certain comments, when matched', 'string'], 'json-regex'],
+ ignoreCustomFragments: [[false, 'Array of regex\'es that allow to ignore certain fragments, when matched (e.g. <?php ... ?>, {{ ... }})', 'string'], 'json-regex'],
+ includeAutoGeneratedTags: [[false, 'Insert tags generated by HTML parser'], true],
+ keepClosingSlash: [[false, 'Keep the trailing slash on singleton elements']],
+ lint: [[false, 'Toggle linting']],
+ maxLineLength: [[false, 'Max line length', 'number'], true],
+ minifyCSS: [[false, 'Minify CSS in style elements and style attributes (uses clean-css)']],
+ minifyJS: [[false, 'Minify Javascript in script elements and on* attributes (uses UglifyJS)']],
+ minifyURLs: [[false, 'Minify URLs in various attributes (uses relateurl)', 'string'], 'site-url'],
+ preserveLineBreaks: [[false, 'Always collapse to 1 line break (never remove it entirely) when whitespace between tags include a line break.']],
+ preventAttributesEscaping: [[false, 'Prevents the escaping of the values of attributes.']],
+ processConditionalComments: [[false, 'Process contents of conditional comments through minifier']],
+ processScripts: [[false, 'Array of strings corresponding to types of script elements to process through minifier (e.g. "text/ng-template", "text/x-handlebars-template", etc.)', 'string'], 'json'],
+ quoteCharacter: [[false, 'Type of quote to use for attribute values (\' or ")', 'string'], true],
+ removeAttributeQuotes: [[false, 'Remove quotes around attributes when possible.']],
+ removeComments: [[false, 'Strip HTML comments']],
+ removeEmptyAttributes: [[false, 'Remove all attributes with whitespace-only values']],
+ removeEmptyElements: [[false, 'Remove all elements with empty contents']],
+ removeOptionalTags: [[false, 'Remove unrequired tags']],
+ removeRedundantAttributes: [[false, 'Remove attributes when value matches default.']],
+ removeScriptTypeAttributes: [[false, 'Remove type="text/javascript" from script tags. Other type attribute values are left intact.']],
+ removeStyleLinkTypeAttributes: [[false, 'Remove type="text/css" from style and link tags. Other type attribute values are left intact.']],
+ removeTagWhitespace: [[false, 'Remove space between attributes whenever possible']],
+ sortAttributes: [[false, 'Sort attributes by frequency']],
+ useShortDoctype: [[false, 'Replaces the doctype with the short (HTML5) doctype']]
};
var cliOptions = {
- version: [ 'v', 'Version information' ],
- output: [ 'o', 'Specify output file (if not specified STDOUT will be used for output)', 'file' ],
- 'config-file': [ 'c', 'Use config file', 'file' ],
- 'input-dir': [ false, 'Specify an input directory', 'dir' ],
- 'output-dir': [ false, 'Specify an output directory', 'dir' ]
+ version: ['v', 'Version information'],
+ output: ['o', 'Specify output file (if not specified STDOUT will be used for output)', 'file'],
+ 'config-file': ['c', 'Use config file', 'file'],
+ 'input-dir': [false, 'Specify an input directory', 'dir'],
+ 'output-dir': [false, 'Specify an output directory', 'dir']
};
var mainOptionKeys = Object.keys(mainOptions);
catch (e) {
cli.fatal('Could not parse JSON value \'' + value + '\'');
}
- return Array.isArray(jsonArray) ? jsonArray : [ value ];
+ return Array.isArray(jsonArray) ? jsonArray : [value];
}
}
}
function Lint() {
- this.log = [ ];
+ this.log = [];
this._lastElement = null;
this._isElementRepeated = false;
}
// Regular Expressions for parsing tags and attributes
var singleAttrIdentifier = /([^\s"'<>\/=]+)/,
singleAttrAssign = /=/,
- singleAttrAssigns = [ singleAttrAssign ],
+ singleAttrAssigns = [singleAttrAssign],
singleAttrValues = [
// attr value double quotes
/"([^"]*)"+/.source,
options.includeAutoGeneratedTags = true;
}
- var defaultTesters = [ 'canCollapseWhitespace', 'canTrimWhitespace' ];
+ var defaultTesters = ['canCollapseWhitespace', 'canTrimWhitespace'];
for (var i = 0, len = defaultTesters.length; i < len; i++) {
if (!options[defaultTesters[i]]) {
options[defaultTesters[i]] = function() {
processOptions(options);
value = options.collapseWhitespace ? trimWhitespace(value) : value;
- var buffer = [ ],
+ var buffer = [],
charsPrevTag,
currentChars = '',
hasChars,
optionalEndTag = '',
lint = options.lint,
t = Date.now(),
- ignoredMarkupChunks = [ ],
- ignoredCustomMarkupChunks = [ ],
+ ignoredMarkupChunks = [],
+ ignoredCustomMarkupChunks = [],
uidIgnore,
uidAttr;
options.sortAttributes(tag, attrs);
}
- var parts = [ ];
+ var parts = [];
var token, isLast = true;
for (var i = attrs.length; --i >= 0;) {
if (lint) {
}
function Lint() {
- this.log = [ ];
+ this.log = [];
this._lastElement = null;
this._isElementRepeated = false;
}
options.includeAutoGeneratedTags = true;
}
- var defaultTesters = [ 'canCollapseWhitespace', 'canTrimWhitespace' ];
+ var defaultTesters = ['canCollapseWhitespace', 'canTrimWhitespace'];
for (var i = 0, len = defaultTesters.length; i < len; i++) {
if (!options[defaultTesters[i]]) {
options[defaultTesters[i]] = function() {
processOptions(options);
value = options.collapseWhitespace ? trimWhitespace(value) : value;
- var buffer = [ ],
+ var buffer = [],
charsPrevTag,
currentChars = '',
hasChars,
optionalEndTag = '',
lint = options.lint,
t = Date.now(),
- ignoredMarkupChunks = [ ],
- ignoredCustomMarkupChunks = [ ],
+ ignoredMarkupChunks = [],
+ ignoredCustomMarkupChunks = [],
uidIgnore,
uidAttr;
options.sortAttributes(tag, attrs);
}
- var parts = [ ];
+ var parts = [];
var token, isLast = true;
for (var i = attrs.length; --i >= 0;) {
if (lint) {
// Regular Expressions for parsing tags and attributes
var singleAttrIdentifier = /([^\s"'<>\/=]+)/,
singleAttrAssign = /=/,
- singleAttrAssigns = [ singleAttrAssign ],
+ singleAttrAssigns = [singleAttrAssign],
singleAttrValues = [
// attr value double quotes
/"([^"]*)"+/.source,
testrunner.options.log.assertions = false;
testrunner.run({
- deps: [ './src/htmlparser.js', './src/htmllint.js' ],
+ deps: ['./src/htmlparser.js', './src/htmllint.js'],
code: './src/htmlminifier.js',
tests: [
'./tests/lint.js',
'use strict';
QUnit.done(function(details) {
- alert(JSON.stringify([ 'qunit.done', details ]));
+ alert(JSON.stringify(['qunit.done', details]));
});
// With a single rule
customAttrOptions = {
- customAttrSurround: [ [ /\{\{#if\s+\w+\}\}/, /\{\{\/if\}\}/ ] ]
+ customAttrSurround: [[/\{\{#if\s+\w+\}\}/, /\{\{\/if\}\}/]]
};
input = '<input {{#if value}}checked="checked"{{/if}}>';
// With multiple rules
customAttrOptions = {
customAttrSurround: [
- [ /\{\{#if\s+\w+\}\}/, /\{\{\/if\}\}/ ],
- [ /\{\{#unless\s+\w+\}\}/, /\{\{\/unless\}\}/ ]
+ [/\{\{#if\s+\w+\}\}/, /\{\{\/if\}\}/],
+ [/\{\{#unless\s+\w+\}\}/, /\{\{\/unless\}\}/]
]
};
// With multiple rules and richer options
customAttrOptions = {
customAttrSurround: [
- [ /\{\{#if\s+\w+\}\}/, /\{\{\/if\}\}/ ],
- [ /\{\{#unless\s+\w+\}\}/, /\{\{\/unless\}\}/ ]
+ [/\{\{#if\s+\w+\}\}/, /\{\{\/if\}\}/],
+ [/\{\{#unless\s+\w+\}\}/, /\{\{\/unless\}\}/]
],
collapseBooleanAttributes: true,
removeAttributeQuotes: true
test('preserving custom attribute-joining markup', function() {
var polymerConditionalAttributeJoin = /\?=/;
var customAttrOptions = {
- customAttrAssign: [ polymerConditionalAttributeJoin ]
+ customAttrAssign: [polymerConditionalAttributeJoin]
};
input = '<div flex?="{{mode != cover}}"></div>';
// https://github.com/kangax/html-minifier/issues/10
test('Ignore custom fragments', function() {
- var reFragments = [ /<\?[^\?]+\?>/, /<%[^%]+%>/, /\{\{[^\}]*\}\}/ ];
+ var reFragments = [/<\?[^\?]+\?>/, /<%[^%]+%>/, /\{\{[^\}]*\}\}/];
input = 'This is the start. <% ... %>\r\n<%= ... %>\r\n<? ... ?>\r\n<!-- This is the middle, and a comment. -->\r\nNo comment, but middle.\r\n{{ ... }}\r\n<?php ... ?>\r\n<?xml ... ?>\r\nHello, this is the end!';
output = 'This is the start. <% ... %> <%= ... %> <? ... ?> No comment, but middle. {{ ... }} <?php ... ?> <?xml ... ?> Hello, this is the end!';
input = '<img src="{% static "images/logo.png" %}">';
output = '<img src="{% static "images/logo.png" %}">';
- equal(minify(input, { ignoreCustomFragments: [ /\{\%[^\%]*?\%\}/g ] }), output);
+ equal(minify(input, { ignoreCustomFragments: [/\{\%[^\%]*?\%\}/g] }), output);
input = '<p{% if form.name.errors %}class=\'error\'{% endif %}>' +
'{{ form.name.label_tag }}' +
output = '<button type="button" onclick="return!1" ng-click="a(1 + 2)" data-click="a(1 + 2)"></button>';
equal(minify(input, { minifyJS: true }), output);
- equal(minify(input, { minifyJS: true, customEventAttributes: [ ] }), input);
+ equal(minify(input, { minifyJS: true, customEventAttributes: [] }), input);
output = '<button type="button" onclick=";return false;" ng-click="a(3)" data-click="a(1 + 2)"></button>';
- equal(minify(input, { minifyJS: true, customEventAttributes: [ /^ng-/ ] }), output);
+ equal(minify(input, { minifyJS: true, customEventAttributes: [/^ng-/] }), output);
output = '<button type="button" onclick="return!1" ng-click="a(3)" data-click="a(1 + 2)"></button>';
- equal(minify(input, { minifyJS: true, customEventAttributes: [ /^on/, /^ng-/ ] }), output);
+ equal(minify(input, { minifyJS: true, customEventAttributes: [/^on/, /^ng-/] }), output);
});
test('escaping closing script tag', function() {
equal(minify(input, {
collapseWhitespace: true,
removeComments: true,
- processScripts: [ 'text/ng-template' ]
+ processScripts: ['text/ng-template']
}), output);
});
input = '<!-- htmlmin:ignore --><body <?php body_class(); ?>><!-- htmlmin:ignore -->';
output = '<body <?php body_class(); ?>>';
- equal(minify(input, { ignoreCustomFragments: [ /<\?php[\s\S]*?\?>/ ] }), output);
+ equal(minify(input, { ignoreCustomFragments: [/<\?php[\s\S]*?\?>/] }), output);
input = 'a\n<!-- htmlmin:ignore -->b<!-- htmlmin:ignore -->';
output = 'a b';
test('tests from PHPTAL', function() {
[
// trailing </p> removed by minifier, but not by PHPTAL
- [ '<p>foo bar baz', '<p>foo \t bar\n\n\n baz</p>' ],
- [ '<p>foo bar<pre> \tfoo\t \nbar </pre>', '<p>foo \t\n bar</p><pre> \tfoo\t \nbar </pre>' ],
- [ '<p>foo <a href="">bar </a>baz', '<p>foo <a href=""> bar </a> baz </p>' ],
- [ '<p>foo <a href="">bar </a>baz', ' <p>foo <a href=""> bar </a>baz </p>' ],
- [ '<p>foo<a href=""> bar </a>baz', ' <p> foo<a href=""> bar </a>baz </p> ' ],
- [ '<p>foo <a href="">bar</a> baz', ' <p> foo <a href="">bar</a> baz</p>' ],
- [ '<p>foo<br>', '<p>foo <br/></p>' ],
+ ['<p>foo bar baz', '<p>foo \t bar\n\n\n baz</p>'],
+ ['<p>foo bar<pre> \tfoo\t \nbar </pre>', '<p>foo \t\n bar</p><pre> \tfoo\t \nbar </pre>'],
+ ['<p>foo <a href="">bar </a>baz', '<p>foo <a href=""> bar </a> baz </p>'],
+ ['<p>foo <a href="">bar </a>baz', ' <p>foo <a href=""> bar </a>baz </p>'],
+ ['<p>foo<a href=""> bar </a>baz', ' <p> foo<a href=""> bar </a>baz </p> '],
+ ['<p>foo <a href="">bar</a> baz', ' <p> foo <a href="">bar</a> baz</p>'],
+ ['<p>foo<br>', '<p>foo <br/></p>'],
// PHPTAL remove whitespace after 'foo' - problematic if <span> is used as icon font
- [ '<p>foo <span></span>', '<p>foo <span></span></p>' ],
- [ '<p>foo <span></span>', '<p>foo <span></span> </p>' ],
+ ['<p>foo <span></span>', '<p>foo <span></span></p>'],
+ ['<p>foo <span></span>', '<p>foo <span></span> </p>'],
// comments removed by minifier, but not by PHPTAL
- [ '<p>foo', '<p>foo <!-- --> </p>' ],
- [ '<div>a<div>b</div>c<div>d</div>e</div>', '<div>a <div>b</div> c <div> d </div> e </div>' ],
+ ['<p>foo', '<p>foo <!-- --> </p>'],
+ ['<div>a<div>b</div>c<div>d</div>e</div>', '<div>a <div>b</div> c <div> d </div> e </div>'],
// unary slashes removed by minifier, but not by PHPTAL
- [ '<div><img></div>', '<div> <img/> </div>' ],
- [ '<div>x <img></div>', '<div> x <img/> </div>' ],
- [ '<div>x <img> y</div>', '<div> x <img/> y </div>' ],
- [ '<div><img> y</div>', '<div><img/> y </div>' ],
- [ '<div><button>Z</button></div>', '<div> <button>Z</button> </div>' ],
- [ '<div>x <button>Z</button></div>', '<div> x <button>Z</button> </div>' ],
- [ '<div>x <button>Z</button> y</div>', '<div> x <button>Z</button> y </div>' ],
- [ '<div><button>Z</button> y</div>', '<div><button>Z</button> y </div>' ],
- [ '<div><button>Z</button></div>', '<div> <button> Z </button> </div>' ],
- [ '<div>x <button>Z</button></div>', '<div> x <button> Z </button> </div>' ],
- [ '<div>x <button>Z</button> y</div>', '<div> x <button> Z </button> y </div>' ],
- [ '<div><button>Z</button> y</div>', '<div><button> Z </button> y </div>' ],
- [ '<script>//foo\nbar()</script>', '<script>//foo\nbar()</script>' ],
+ ['<div><img></div>', '<div> <img/> </div>'],
+ ['<div>x <img></div>', '<div> x <img/> </div>'],
+ ['<div>x <img> y</div>', '<div> x <img/> y </div>'],
+ ['<div><img> y</div>', '<div><img/> y </div>'],
+ ['<div><button>Z</button></div>', '<div> <button>Z</button> </div>'],
+ ['<div>x <button>Z</button></div>', '<div> x <button>Z</button> </div>'],
+ ['<div>x <button>Z</button> y</div>', '<div> x <button>Z</button> y </div>'],
+ ['<div><button>Z</button> y</div>', '<div><button>Z</button> y </div>'],
+ ['<div><button>Z</button></div>', '<div> <button> Z </button> </div>'],
+ ['<div>x <button>Z</button></div>', '<div> x <button> Z </button> </div>'],
+ ['<div>x <button>Z</button> y</div>', '<div> x <button> Z </button> y </div>'],
+ ['<div><button>Z</button> y</div>', '<div><button> Z </button> y </div>'],
+ ['<script>//foo\nbar()</script>', '<script>//foo\nbar()</script>'],
// optional tags removed by minifier, but not by PHPTAL
// parser cannot handle <script/>
[
' > </style >\n' +
' </head > </html>'
],
- [ '<div><p>test 123<p>456<ul><li>x</ul></div>', '<div> <p> test 123 </p> <p> 456 </p> <ul> <li>x</li> </ul> </div>' ],
- [ '<div><p>test 123<pre> 456 </pre><p>x</div>', '<div> <p> test 123 </p> <pre> 456 </pre> <p> x </p> </div>' ],
+ ['<div><p>test 123<p>456<ul><li>x</ul></div>', '<div> <p> test 123 </p> <p> 456 </p> <ul> <li>x</li> </ul> </div>'],
+ ['<div><p>test 123<pre> 456 </pre><p>x</div>', '<div> <p> test 123 </p> <pre> 456 </pre> <p> x </p> </div>'],
/* minifier does not assume <li> as "display: inline"
- ['<div><ul><li><a>a </a></li><li>b </li><li>c</li></ul></div>', '<div> <ul> <li> <a> a </a> </li> <li> b </li> <li> c </li> </ul> </div>'],
- */
- [ '<table>x<tr>x<td>foo</td>x</tr>x</table>', '<table> x <tr> x <td> foo </td> x </tr> x </table>' ],
- [ '<select>x<option></option>x<optgroup>x<option></option>x</optgroup>x</select>', '<select> x <option> </option> x <optgroup> x <option> </option> x </optgroup> x </select> ' ],
+ ['<div><ul><li><a>a </a></li><li>b </li><li>c</li></ul></div>', '<div> <ul> <li> <a> a </a> </li> <li> b </li> <li> c </li> </ul> </div>'],*/
+ ['<table>x<tr>x<td>foo</td>x</tr>x</table>', '<table> x <tr> x <td> foo </td> x </tr> x </table>'],
+ ['<select>x<option></option>x<optgroup>x<option></option>x</optgroup>x</select>', '<select> x <option> </option> x <optgroup> x <option> </option> x </optgroup> x </select> '],
/* minifier does not reorder attributes
['<img src="foo" width="10" height="5" alt="x"/>', '<img width="10" height="5" src="foo" alt="x" />'],
- ['<img alpha="1" beta="2" gamma="3"/>', '<img gamma="3" alpha="1" beta="2" />'],
- */
- [ '<pre>\n\n\ntest</pre>', '<pre>\n\n\ntest</pre>' ],
+ ['<img alpha="1" beta="2" gamma="3"/>', '<img gamma="3" alpha="1" beta="2" />'],*/
+ ['<pre>\n\n\ntest</pre>', '<pre>\n\n\ntest</pre>'],
/* single line-break preceding <pre> is redundant, assuming <pre> is block element
- ['<pre>test</pre>', '<pre>\ntest</pre>'],
- */
+ ['<pre>test</pre>', '<pre>\ntest</pre>'],*/
// optional attribute quotes removed by minifier, but not by PHPTAL
- [ '<meta http-equiv=Content-Type content="text/plain;charset=UTF-8">', '<meta http-equiv=\'Content-Type\' content=\'text/plain;charset=UTF-8\'/>' ],
+ ['<meta http-equiv=Content-Type content="text/plain;charset=UTF-8">', '<meta http-equiv=\'Content-Type\' content=\'text/plain;charset=UTF-8\'/>'],
/* minifier does not optimise <meta/> in HTML5 mode
- ['<meta charset=utf-8>', '<meta http-equiv=\'Content-Type\' content=\'text/plain;charset=UTF-8\'/>'],
- */
+ ['<meta charset=utf-8>', '<meta http-equiv=\'Content-Type\' content=\'text/plain;charset=UTF-8\'/>'],*/
/* minifier does not optimise <script/> in HTML5 mode
[
'<script></script><style></style>',
'<script type=\'text/javascript ;charset=utf-8\'\n' +
'language=\'javascript\'></script><style type=\'text/css\'></style>'
- ],
- */
- [ '<script type="text/javascript;e4x=1"></script><script type=text/hack></script>', '<script type="text/javascript;e4x=1"></script><script type="text/hack"></script>' ]
+ ],*/
+ ['<script type="text/javascript;e4x=1"></script><script type=text/hack></script>', '<script type="text/javascript;e4x=1"></script><script type="text/hack"></script>']
/* trim "title" attribute value in <a>
[
'<title>Foo</title><p><a title=\"x\"href=test>x </a>xu</p><br>foo',
'</p>\n' +
'<br/>\n' +
'foo</body> </html> <!-- bla -->'
- ]
- */
+ ]*/
].forEach(function(tokens) {
equal(minify(tokens[1], {
collapseBooleanAttributes: true,