dave-kennedy / clean-html

HTML cleaner and beautifier for Node
The Unlicense
47 stars 10 forks source link

can clean-html remove empty attriubtes ? #9

Open dfang opened 7 years ago

dfang commented 7 years ago

as title

thanks

dave-kennedy commented 7 years ago

You're asking if it will change:

<div class="">stuff</div>

to:

<div>stuff</div>

Is that it?

Sounds like a good idea. Unfortunately I don't think it currently does. Would gladly accept a PR.

castastrophe commented 5 years ago

Just a note that some empty attributes are valid. Boolean attributes for example: http://w3c.github.io/html/infrastructure.html#boolean-attribute

A boolean attribute without a value assigned to it (e.g. checked) is implicitly equivalent to one that has the empty string assigned to it (i.e. checked=""). As a consequence, it represents the true value.

castastrophe commented 5 years ago

I mention this because a similar issue that I hope to open a PR for soon is that it's actually adding ="" to my boolean selectors and I would like to be able to configure that off.

castastrophe commented 5 years ago

I think this PR might help solve your and my issue: https://github.com/dave-kennedy/clean-html/pull/17

dave-kennedy commented 1 year ago

Just FYI the new allow-attributes-without-values addresses the boolean attributes issue you mentioned.