Skip to content

[Bug]: can't disable normalizeAttr/cleanAttributeValue #191

@slorber

Description

@slorber

What happened?

There is no way to opt-out of attribute normalization.

The problem is that transforming class=" xyz " to class="xyz" can lead to React hydration errors, and the minifier does not give us any escape hatch option to turn this normalization off.

Of course, it's better to not have such useless whitespace in the markup in the first place, but sometimes that extra whitespace comes from a third-party npm package and you can't easily fix it in userland.

Here's an example I encountered on the Docusaurus website:

CleanShot 2024-12-20 at 23 08 40@2x

Note that @swc/html minifier has such an option already: normalizeAttributes: false,

Version

7.2.0

What browsers are you seeing the problem on?

No response

Link to reproduce

No response

Relevant log output

No response

Willing to submit a PR?

None

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions