`Document.parseHTMLUnsafe` drops HTML comments in Chrome 155, so swapped content loses them
Maintainers usually reply within 5 days
@Aashu-1911 is already working on this.
Since Oct 18, 2026.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 65/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Active
- Tech stack
- html, javascript
- Domain
- frontend
Research direction
Start by reading the HTML parsing selection introduced in #3185 and trace how htmx chooses between Document.parseHTMLUnsafe and DOMParser. Add coverage for HTML comments in swapped content, including the reported Chrome behavior, and verify the proposed configuration option selects DOMParser. Done means users can opt into parsing that preserves comments and the regression is covered by tests.
Written by the indexing model from the issue text.
Description
In Chrome 155, Document.parseHTMLUnsafe drops every HTML comment. DOMParser keeps them, and Chromium 148 kept them too. htmx 2 and htmx 4 both prefer parseHTMLUnsafe when the browser has it (since #3185), so any comment in swapped content is lost.
| Input | Chrome 155 parseHTMLUnsafe |
Chrome 155 DOMParser |
Chromium 148 parseHTMLUnsafe |
|---|---|---|---|
<p>a<!-- x -->b</p> |
<p>ab</p> |
<p>a<!-- x -->b</p> |
<p>a<!-- x -->b</p> |
<p>a<!---->b</p> |
<p>ab</p> |
<p>a<!---->b</p> |
<p>a<!---->b</p> |
This breaks libraries that hydrate server-rendered HTML using comment markers. For example, Leptos islands swapped in by htmx 2 fail to hydrate (htmx 4 calls the same function, not tested in Chrome 155). The workaround today is delete Document.parseHTMLUnsafe before htmx loads (https://github.com/leptos-rs/leptos/pull/4910).
It's a Chrome bug, reported a month ago: https://issues.chromium.org/issues/562116090 (point 3). Passing {} as the second argument, Document.parseHTMLUnsafe(html, {}), keeps the comments, and is correct per spec. Would you take a PR for that one-line change?
Drafted with Claude, reviewed by me.
- Dominant language
- JavaScript
- Stars
- 49.6k
- Forks
- 1.7k
- Avg merge
- 14d 7h
- Merged PRs (30d)
- 10
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from bigskysoftware/htmx
-
[htmx4] Swap style for boosted elements is not outerSyncPossibly taken @1cg claimed this 3 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
bigskysoftware/htmx#4138 · 3 comments · 1 assignee ·
Maintainers usually reply within 5 days
-
[htmx4] HTMX errors if HX-Trigger Event Detail is nullPossibly taken @MichaelWest22 claimed this 3 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
bigskysoftware/htmx#4135 · 3 comments · 1 assignee ·
Maintainers usually reply within 5 days
-
[htmx4]: an `hx-trigger` filter throws a SyntaxError when the event has a property that isn't an identifierPossibly taken @MichaelWest22 claimed this 3 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
bigskysoftware/htmx#4123 · 1 assignee ·
Maintainers usually reply within 5 days
-
[htmx4] When importing and configuring htmx with JS, you can't turn off indicator CSSPossibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
bigskysoftware/htmx#4122 · 1 comment · 1 assignee ·
Maintainers usually reply within 5 days
-
No GitHub Release for version 2.0.11Possibly taken @1cg claimed this 3 days ago. Open
Difficulty 1/5 Under an hour Newbie friendliness 75/100
bigskysoftware/htmx#4117 · 1 assignee ·
Maintainers usually reply within 5 days
All issues in bigskysoftware/htmx
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 83/100
Maintainers usually reply within 2 days
-
feedback simulation workshop
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
githubnext/gh-aw-workshop#4755 ·
Maintainers usually reply within 1 day
-
fix
Difficulty 1/5 Under an hour Newbie friendliness 72/100
idean3885/claude-ops-agent#728 ·
Maintainers usually reply within 1 day
-
deck: add to staging level: easy p-feature: Privacy Policy priority: MUST HAVE ready for product role: front-end size: 0.25pt Waiting on Stakeholder
Difficulty 2/5 1-3 hours Newbie friendliness 61/100
hackforla/tdm-calculator#3654 · 1 comment ·
Maintainers usually reply within 1 day
-
Add: Sony Vizha HDOpencheck:failed feeds:add
Difficulty 1/5 Under an hour Newbie friendliness 78/100