Skip to content

Serialize empty attribute values without =""#325

Open
gjtorikian wants to merge 1 commit into
cloudflare:mainfrom
gjtorikian:bool-serialize
Open

Serialize empty attribute values without =""#325
gjtorikian wants to merge 1 commit into
cloudflare:mainfrom
gjtorikian:bool-serialize

Conversation

@gjtorikian
Copy link
Copy Markdown
Contributor

When Element::set_attribute is called with an empty value, emit the attribute as a valueless attribute (e.g. <p data-thing>) rather than <p data-thing="">.

The two are equivalent per the HTML spec, but the valueless form is what callers asking for "add a boolean attribute" expect to see in the output. Original raw attributes from the input are still emitted verbatim, so this only affects programmatically added/modified attributes.

Closes #205.

@gjtorikian gjtorikian requested review from a team, Noah-Kennedy, jasnell and orium as code owners June 3, 2026 15:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support for Element::add_attribute

1 participant