[RENDERER]: only the first raw text element with interpolations is handled, a line break inside one breaks it too

Aperta Adatta ai principianti
#185 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@eddyloewen ci sta già lavorando.

Dal 28/10/2026.

  • #188 di @eddyloewen — aperta

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
88/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
javascript
Ambito
frontend

Direzione di ricerca

Leggi src/dom-parts/TemplateResult.js e i casi esistenti in test/unit/raw-text-node-part.test.js. Aggiungi test per più elementi di testo semplice con interpolazioni e per un'interpolazione dopo un'interruzione di riga. Verifica quindi che entrambi i template producano parti analizzate correttamente senza ParseTemplateError.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

bug

Repro

// two <style> elements with one interpolation each
html`<style>${a}</style><style>${b}</style>`

// one <style> with a line break before the interpolation
html`<style>
    .a { color: ${c} }
</style>`

createTemplateString() output for the first template:

<!--template-part--><!--dom-part-0?type=raw-text-node&initialValue=%03--><style></style><style><!--dom-part-1--><!--/dom-part-1--></style><!--/template-part-->

The second <style> gets a node part marker inside the element. The browser parses a comment inside <style> as text, so parseParts() finds one marker for two values and throws ParseTemplateError. The multiline template gets the same marker inside the element and no raw text part at all.

Cause

src/dom-parts/TemplateResult.js:7:

const rawTextElements = /<(script|style|textarea|title)([^>]*)>(.*?)<\/\1>/i;

No g flag, so template.replace(rawTextElements, …) handles the first match only. No s flag, so .*? stops at a line break and a multiline element does not match at all.

Fix

Add the two flags, with a test for each case in test/unit/raw-text-node-part.test.js. The parser is replaced in #184, the flags are the fix until then.

Lingua principale
JavaScript
Stelle
30
Fork
5
Merge medio
1h 57m
PR unite (30g)
10

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di webtides/element-js

Tutte le issue di webtides/element-js

Issue simili

Altre issue su JavaScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.