Skip to content

fix: serialize attributes through quoteAttribute in removeWhitespace#310

Merged
taoqf merged 1 commit into
taoqf:mainfrom
greymoth-jp:fix-removewhitespace-attr-serialization
Jun 29, 2026
Merged

fix: serialize attributes through quoteAttribute in removeWhitespace#310
taoqf merged 1 commit into
taoqf:mainfrom
greymoth-jp:fix-removewhitespace-attr-serialization

Conversation

@greymoth-jp

Copy link
Copy Markdown

removeWhitespace() rebuilds rawAttrs to drop the whitespace between attributes, but it serializes each value with JSON.stringify(val) instead of going through quoteAttribute, the helper the other write paths use. That leaves it with the two bugs the helper already handles, so removeWhitespace() corrupts attribute values:

The fix routes the value through quoteAttribute and applies the same valueless-attribute guard the three other serialization sites (setAttribute, removeAttribute, setAttributes) already use, so all four paths agree.

I added two regression tests under #removeWhitespace(). Without the change they fail with the corrupted output above; with it the suite passes.

@taoqf taoqf merged commit e76e938 into taoqf:main Jun 29, 2026
3 checks passed
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.

2 participants