kangax / html-minifier

Javascript-based HTML compressor/minifier (with Node.js support)
http://kangax.github.io/html-minifier/
MIT License
4.94k stars 571 forks source link

Fixing exceptions when attribute contains no value #1056

Open Chopinsky opened 4 years ago

Chopinsky commented 4 years ago

This PR is to address the exception being thrown if the target html file contains link tags whose type attribute is defined but without a value.

For example, when using the plugin with webpack, encountering the following link tag:

<link href="https://somecdn.com/favicon/favicon.png" rel="icon" type>

in a html file will crash the build process because of this exception: TypeError: Cannot read property 'toLowerCase' of undefined.

With this fix, we will treat the undefined attribute value as a blank string value, i.e. it will be equivalent as the link tag below:

<link href="https://somecdn.com/favicon/favicon.png" rel="icon" type="">.