Skip to content

fix(format/html): fix double emitting comments sometimes#8889

Draft
dyc3 wants to merge 2 commits intonextfrom
dyc3/fix-double-emit-comment
Draft

fix(format/html): fix double emitting comments sometimes#8889
dyc3 wants to merge 2 commits intonextfrom
dyc3/fix-double-emit-comment

Conversation

@dyc3
Copy link
Contributor

@dyc3 dyc3 commented Jan 27, 2026

Summary

Prettier's parser fundamentally treats comments differently than we do. It treats comments as actual nodes in the markup, but we treat them as trivia. To match this behavior more closely, we try to split children of an element into an iter of HtmlChild so we can iterate over the children easier.

This PR fixes a case where that wasn't happening correctly. Now we prefer the comment we get as an HtmlChild, and skip formatting it as trivia.

Generated by opus 4.5

fixes #8803

Test Plan

Added snapshots.

Docs

@changeset-bot
Copy link

changeset-bot bot commented Jan 27, 2026

🦋 Changeset detected

Latest commit: 32da29c

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 13 packages
Name Type
@biomejs/biome Patch
@biomejs/cli-win32-x64 Patch
@biomejs/cli-win32-arm64 Patch
@biomejs/cli-darwin-x64 Patch
@biomejs/cli-darwin-arm64 Patch
@biomejs/cli-linux-x64 Patch
@biomejs/cli-linux-arm64 Patch
@biomejs/cli-linux-x64-musl Patch
@biomejs/cli-linux-arm64-musl Patch
@biomejs/wasm-web Patch
@biomejs/wasm-bundler Patch
@biomejs/wasm-nodejs Patch
@biomejs/backend-jsonrpc Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions bot added A-Formatter Area: formatter L-HTML Language: HTML and super languages labels Jan 27, 2026
@codspeed-hq
Copy link

codspeed-hq bot commented Jan 27, 2026

Merging this PR will degrade performance by 7.19%

❌ 2 regressed benchmarks
✅ 1 untouched benchmark
🆕 1 new benchmark
⏩ 152 skipped benchmarks1

⚠️ Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Benchmark BASE HEAD Efficiency
index_1033418810622582172.html[cached] 102 µs 109.9 µs -7.19%
index_1033418810622582172.html[uncached] 118.2 µs 126.6 µs -6.65%
🆕 html_analyzer[index_1033418810622582172.html] N/A 397.8 µs N/A

Comparing dyc3/fix-double-emit-comment (32da29c) with next (0e8e623)

Open in CodSpeed

Footnotes

  1. 152 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@dyc3 dyc3 force-pushed the dyc3/fix-double-emit-comment branch from 62a73c8 to bf64f5e Compare January 29, 2026 01:40
@dyc3 dyc3 force-pushed the dyc3/fix-double-emit-comment branch from bf64f5e to 32da29c Compare January 29, 2026 01:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Formatter Area: formatter L-HTML Language: HTML and super languages

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Comments