From ac3f8ca61b5045d3a3e77a136befe0ac48f81176 Mon Sep 17 00:00:00 2001 From: Jasper De Moor Date: Sun, 29 Apr 2018 03:55:40 +0200 Subject: [PATCH] change default behaviour to keep default values of form elements (#1249) --- src/transforms/htmlnano.js | 1 + test/html.js | 10 ++++++++++ test/integration/htmlnano-defaults-form/index.html | 11 +++++++++++ 3 files changed, 22 insertions(+) create mode 100644 test/integration/htmlnano-defaults-form/index.html diff --git a/src/transforms/htmlnano.js b/src/transforms/htmlnano.js index 1b9c9092a27..7258b314668 100644 --- a/src/transforms/htmlnano.js +++ b/src/transforms/htmlnano.js @@ -7,6 +7,7 @@ module.exports = async function(asset) { const htmlNanoConfig = asset.package.htmlnano || (await asset.getConfig(['.htmlnanorc', '.htmlnanorc.js'])) || { collapseWhitespace: 'conservative', + removeRedundantAttributes: false, minifyCss: { safe: true } diff --git a/test/html.js b/test/html.js index b1867025d27..10cbd4212d2 100644 --- a/test/html.js +++ b/test/html.js @@ -290,6 +290,16 @@ describe('html', function() { ); }); + it('should not minify default values inside HTML in production mode', async function() { + await bundle(__dirname + '/integration/htmlnano-defaults-form/index.html', { + production: true + }); + + let html = fs.readFileSync(__dirname + '/dist/index.html', 'utf8'); + assert(html.includes('')); + assert(!html.includes('\n')); + }); + it('should not prepend the public path to assets with remote URLs', async function() { await bundle(__dirname + '/integration/html/index.html'); diff --git a/test/integration/htmlnano-defaults-form/index.html b/test/integration/htmlnano-defaults-form/index.html new file mode 100644 index 00000000000..57ebcc655c2 --- /dev/null +++ b/test/integration/htmlnano-defaults-form/index.html @@ -0,0 +1,11 @@ + + + + Test + + +
+ +
+ +