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

オープン 初心者向け
#185 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@eddyloewen がすでに取り組んでいます。

2026年10月28日 から。

  • #188 @eddyloewen による — オープン

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
88/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
javascript
領域
frontend

調査の方向性

src/dom-parts/TemplateResult.jsとtest/unit/raw-text-node-part.test.jsの既存のケースを読みます。複数の raw text 要素に補間がある場合と、改行後に補間がある場合のテストを追加します。その後、どちらのテンプレートもParseTemplateErrorを発生させず、パーツが正しく解析されることを確認します。

索引モデルが issue の本文から書いたものです。

説明

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.

主要言語
JavaScript
スター
30
フォーク
5
平均マージ
1時間 57分
マージ済み PR(30日)
10

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

webtides/element-js のほかの issue

webtides/element-js の issue をすべて見る

似ている issue

JavaScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。