apostrophecms / sanitize-html

Clean up user-submitted HTML, preserving whitelisted elements and whitelisted attributes on a per-element basis. Built on htmlparser2 for speed and tolerance
MIT License
3.68k stars 349 forks source link

feat: remove empty non-boolean attributes #624

Closed dylanarmstrong closed 1 year ago

dylanarmstrong commented 1 year ago

Summary

This causes sanitize-html to remove empty attributes that are known to be non-boolean. It provides an exhaustive list of all known attributes taken from: https://html.spec.whatwg.org/multipage/indices.html#attributes-3

Closes #123

What are the specific steps to test this change?

Test with empty attributes such as:

<input checked type="checkbox" />

Will not remove anything.

<input checked form type="checkbox" />

Will transform into the first example.

What kind of change does this PR introduce?

Make sure the PR fulfills these requirements:

If adding a new feature without an already open issue, it's best to open a feature request issue first and wait for approval before working on it.

dylanarmstrong commented 1 year ago

Thanks for feedback, updated documentation.