`Document.parseHTMLUnsafe` drops HTML comments in Chrome 155, so swapped content loses them
I maintainer di solito rispondono entro 2 giorni
@Aashu-1911 ci sta già lavorando.
Dal 18/10/2026.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 65/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Attiva
- Stack tecnologico
- html, javascript
- Ambito
- frontend
Direzione di ricerca
Inizia leggendo la selezione del parsing HTML introdotta in #3185 e segui come htmx sceglie tra Document.parseHTMLUnsafe e DOMParser. Aggiungi test per i commenti HTML nel contenuto scambiato, incluso il comportamento segnalato di Chrome, e verifica che l’opzione di configurazione proposta selezioni DOMParser. Il lavoro è completo quando gli utenti possono scegliere un parsing che preserva i commenti e la regressione è coperta dai test.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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.
- Lingua principale
- JavaScript
- Stelle
- 49.6k
- Fork
- 1.7k
- Merge medio
- 22h 2m
- PR unite (30g)
- 6
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di bigskysoftware/htmx
-
Only the first `from:body target:` trigger fires when there are two on htmx 2Forse già presa Una pull request collegata a questa issue è aperta o già unita. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
bigskysoftware/htmx#4155 ·
I maintainer di solito rispondono entro 2 giorni
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
bigskysoftware/htmx#4151 · 1 commento ·
I maintainer di solito rispondono entro 2 giorni
-
[htmx4] Swap style for boosted elements is not outerSyncForse già presa @1cg l’ha presa 10 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
bigskysoftware/htmx#4138 · 3 commenti · 1 assegnatario ·
I maintainer di solito rispondono entro 2 giorni
-
[htmx4] When importing and configuring htmx with JS, you can't turn off indicator CSSForse già presa @MichaelWest22 l’ha presa 10 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
bigskysoftware/htmx#4122 · 1 commento · 1 assegnatario ·
I maintainer di solito rispondono entro 2 giorni
-
No GitHub Release for version 2.0.11Forse già presa @1cg l’ha presa 10 giorni fa. Aperta
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 75/100
bigskysoftware/htmx#4117 · 1 assegnatario ·
I maintainer di solito rispondono entro 2 giorni
Tutte le issue di bigskysoftware/htmx
Issue simili
-
WebsiteApertagood first issue
Difficoltà 2/5 1-3 ore Idoneità per principianti 91/100
TanbirRamim/open-source-radar#314 ·
I maintainer di solito rispondono entro 1 giorno
-
prio: medium
Difficoltà 2/5 1-3 ore Idoneità per principianti 63/100
twentyhq/twenty#28826 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
status: needs triage
Difficoltà 1/5 1-3 ore Idoneità per principianti 76/100
mastra-ai/mastra#28382 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
documentation
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
SolidGeeks/strata#21 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
Yomguithereal/mnemonist#247 ·