[RENDERER]: keep template instances across switches with a cache() directive
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 35/100
- issue の種類
- 機能追加
- 明瞭さ
- おおむね明確
- 活発さ
- 活発
- 技術スタック
- javascript
- 領域
- frontend
調査の方向性
The work sits in the child node part and TemplatePart that #189 is reworking, so start there and read how the part tracks its markers and fragment, plus the existing unsafeHTML() directive as the model for a value wrapper. Add a cache() directive whose part keeps a Map from template strings to TemplatePart instances and moves nodes into the fragment instead of removing them. Done when toggling two templates keeps the same edit-form instance and its typed input value, template to null to template reuses the cached instance, and toString() output matches with and without cache(). Depends on #189 landing first.
索引モデルが issue の本文から書いたものです。
説明
Goal
A child node value that switches between templates, or between a template and something else, can opt into keeping the DOM of the template that went away. When it comes back the same nodes are reinserted, so custom elements keep their instance and state that lives only in the DOM survives: input values, an opened <details>, scroll position.
Context
Since #189 a child node part that switches from a template to another value and back renders the template fresh. 1.3 kept the TemplatePart and reinserted its nodes. Keeping every template that went away is the wrong default: it holds the DOM in memory for the lifetime of the part, and most switches do not need it. Lit has the same default and offers cache() as the opt-in.
Lists are not in scope, keyed lists are #186.
Design
html`<section>${cache(this.editing ? html`<edit-form .item=${this.item}></edit-form>` : html`<p>${this.item.name}</p>`)}</section>`
cache()returns a plain object that carries the value, likeunsafeHTML(), and the child node part recognises it- the part keeps a
Map<strings, TemplatePart>with one instance per literal it has rendered - a template that goes away has its nodes moved from between its markers into its fragment instead of being removed,
TemplatePart.insertBefore()already inserts the fragment - a template that comes back takes its cached instance, gets updated with the new values and is inserted
- a non template value renders as usual, the cached instances stay in the map
- the map is released with the part
toString()renders the value as if there were nocache(), hydration binds the first value as usual
Builds on the range model of #189, do it after that one.
Done when
- toggling between two templates keeps the same
<edit-form>instance and the value typed into an input inside it - template →
null→ template reuses the cached instance toString()output is the same with and withoutcache()- documented in
docs/features/templates.mdnext to the other directives
- 主要言語
- JavaScript
- スター
- 30
- フォーク
- 5
- 平均マージ
- 1時間 57分
- マージ済み PR(30日)
- 10
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
webtides/element-js のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
webtides/element-js#201 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
webtides/element-js#198 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
webtides/element-js#194 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
webtides/element-js#193 ·
メンテナーはふだん 1 日以内に返信
-
[RENDERER]: only the first raw text element with interpolations is handled, a line break inside one breaks it too対応中かも @eddyloewen が 28 日前に担当しました。 オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
webtides/element-js#185 ·
メンテナーはふだん 1 日以内に返信
webtides/element-js の issue をすべて見る
似ている issue
-
area:testing bug effort:low model:light plan planner:gpt-6-2-sol tests
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
enhancement good first issue
難易度 2/5 1〜3時間 初心者へのやさしさ 86/100
Agent360dk/browser-mcp#124 ·
メンテナーはふだん 2 日以内に返信
-
area:site feature good first issue help wanted
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
pacocartones/free-llm-api-hub#829 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
bug
難易度 1/5 1〜3時間 初心者へのやさしさ 78/100
Jason-Vaughan/TangleClaw#3270 ·
メンテナーはふだん 1 日以内に返信