Skip to content

Commit

Permalink
fix: avoid removing redundant attributes (#324)
Browse files Browse the repository at this point in the history
  • Loading branch information
evilebottnawi authored Sep 21, 2020
1 parent 2e0b71e commit ab299ac
Show file tree
Hide file tree
Showing 8 changed files with 802 additions and 588 deletions.
1,222 changes: 698 additions & 524 deletions package-lock.json

Large diffs are not rendered by default.

30 changes: 15 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,37 +46,37 @@
"html-minifier-terser": "^5.1.1",
"htmlparser2": "^4.1.0",
"loader-utils": "^2.0.0",
"schema-utils": "^2.7.0"
"schema-utils": "^2.7.1"
},
"devDependencies": {
"@babel/cli": "^7.10.5",
"@babel/core": "^7.11.1",
"@babel/preset-env": "^7.11.0",
"@commitlint/cli": "^10.0.0",
"@commitlint/config-conventional": "^10.0.0",
"@babel/cli": "^7.11.6",
"@babel/core": "^7.11.6",
"@babel/preset-env": "^7.11.5",
"@commitlint/cli": "^11.0.0",
"@commitlint/config-conventional": "^11.0.0",
"@webpack-contrib/defaults": "^6.3.0",
"@webpack-contrib/eslint-config-webpack": "^3.0.0",
"babel-jest": "^26.3.0",
"cross-env": "^7.0.2",
"del": "^5.1.0",
"del-cli": "^3.0.1",
"es-check": "^5.1.0",
"eslint": "^7.7.0",
"eslint": "^7.9.0",
"eslint-config-prettier": "^6.11.0",
"eslint-plugin-import": "^2.22.0",
"file-loader": "^6.0.0",
"file-loader": "^6.1.0",
"handlebars": "^4.7.6",
"husky": "^4.2.5",
"jest": "^26.4.0",
"lint-staged": "^10.2.11",
"husky": "^4.3.0",
"jest": "^26.4.2",
"lint-staged": "^10.4.0",
"memfs": "^3.2.0",
"npm-run-all": "^4.1.5",
"posthtml": "^0.13.2",
"posthtml-webp": "^1.5.0",
"prettier": "^2.0.5",
"posthtml": "^0.13.3",
"posthtml-webp": "^2.1.0",
"prettier": "^2.1.2",
"standard-version": "^9.0.0",
"url-loader": "^4.1.0",
"webpack": "^4.44.1"
"webpack": "^4.44.2"
},
"keywords": [
"webpack",
Expand Down
4 changes: 2 additions & 2 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -398,8 +398,8 @@ const defaultMinimizerOptions = {
// `minifyURLs` is unsafe, because we can't guarantee what the base URL is
// `removeAttributeQuotes` is not safe in some rare cases, also HTML spec recommends against doing this
removeComments: true,
// `removeEmptyAttributes` is not safe, can affect certain style or script behavior
removeRedundantAttributes: true,
// `removeEmptyAttributes` is not safe, can affect certain style or script behavior, look at https://github.com/webpack-contrib/html-loader/issues/323
// `removeRedundantAttributes` is not safe, can affect certain style or script behavior, look at https://github.com/webpack-contrib/html-loader/issues/323
removeScriptTypeAttributes: true,
removeStyleLinkTypeAttributes: true,
// `useShortDoctype` is not safe for XHTML
Expand Down
72 changes: 48 additions & 24 deletions test/__snapshots__/attributes-option.test.js.snap

Large diffs are not rendered by default.

18 changes: 12 additions & 6 deletions test/__snapshots__/esModule-option.test.js.snap

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions test/__snapshots__/loader.test.js.snap

Large diffs are not rendered by default.

34 changes: 20 additions & 14 deletions test/__snapshots__/minimize-option.test.js.snap

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion test/fixtures/simple.html
Original file line number Diff line number Diff line change
Expand Up @@ -355,4 +355,6 @@ <h2>An Ordered HTML List</h2>
</svg>
<svg>
<script type="application/json" xlink:href="./script.file.js"></script>
</svg>
</svg>

<input type="text" name="test">

0 comments on commit ab299ac

Please sign in to comment.