[UPDATES]: one update cycle for elements and stores, hooks and watchers run once per batch
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 初心者へのやさしさ
- 35/100
- issue の種類
- 機能追加
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- javascript
- 領域
- frontend
調査の方向性
Start with requestUpdate() and Store.requestUpdate(), then inspect test/unit/updates.test.js and the related store tests to map current scheduling and watcher behavior. The design calls for one shared microtask cycle across elements and stores, covering connection handling, observers, and server rendering. Done means the listed update and store behaviors pass, the element-js-ssr-renderer suite stays green, and docs/features/watch.md and docs/features/store.md describe the cycle and hook arguments.
索引モデルが issue の本文から書いたものです。
説明
Goal
A property set schedules one update cycle. Any number of sets on an element or a store in the same tick end in one render, one beforeUpdate, one afterUpdate and one watcher call per changed property. Elements and stores share the cycle: a store notifies each observer once per tick, and a property that a watcher derives from another one lands in the same render.
Context
requestUpdate()triggersbeforeUpdateon every call and reschedules therequestAnimationFrame. Two property sets call the hook twice for one render. The batching test intest/unit/updates.test.jsis commented out because of this.- Watchers run in the
.finally()of each request's promise, after the render. A property that a watcher sets renders one frame later. Setting the same property three times in a tick calls its watcher three times, with the intermediate values. - The frame callback uses the options of the last request. A
requestUpdate({ notify: false })after a notifying request silences the hooks of the whole batch. disconnectedCallback()cancels the frame and drops the pending resolvers. An awaitedrequestUpdate()on an element that leaves the DOM never settles.Store.requestUpdate()has no batching. Every set notifies every observer, callsobserver.watch()twice, passes(store, store)as new and old value (#108) and dispatches one-changedevent per set (#91). Store watchers run synchronously before the update, element watchers after it.requestAnimationFramepauses in background tabs, an awaited update hangs there.
Design
One scheduler for BaseElement and Store, microtask based:
// in the property setter
this._changedProperties ??= new Map();
if (!this._changedProperties.has(property)) this._changedProperties.set(property, oldValue);
this._state[property] = newValue;
this._updatePromise ??= Promise.resolve().then(() => this.performUpdate());
performUpdate() {
const changed = this._changedProperties;
this.beforeUpdate(changed);
for (const [property, oldValue] of changed) this.watch()[property]?.(this[property], oldValue);
this.update();
this.afterUpdate(changed);
// notify events, resolve updateComplete
}
changedPropertiesis aMap<property, oldValue>. The first old value of a tick wins, the last new value is on the instance.beforeUpdateandafterUpdatereceive the map as an optional argument,watch()keeps its(newValue, oldValue)signature.- The first set of a tick queues
performUpdate()as a microtask.requestUpdate()queues the same cycle with no changed property and returnsupdateComplete, so the current API keeps working. - Watchers run before the render, once per changed property. A set made in
beforeUpdateor in a watcher joins the running cycle, its watcher runs in the same loop, and the render sees the derived value. A set made inafterUpdatestarts a new cycle. updateCompleteresolves after the cycle.disconnectedCallback()lets a pending cycle settle, nothing dangles.- The first cycle after connect runs
connected()andafterUpdate()withoutbeforeUpdate, as it does today. Thenotifyoption goes away in favor of this first-cycle rule. performUpdate()returns early for an element that is not connected and keeps the changed properties, the connect runs the cycle. This also covers the server: the dom-shim ofelement-js-ssr-renderernever connects an element, so property sets during a server render schedule nothing, as the no-oprequestAnimationFramedoes today.Storeruns the same scheduler. A set marks the key as changed and queues one microtask.performUpdate()runs the store's own watchers once per key, then notifies each observer once: an element getsrequestUpdate()and its watcher for the store property receives(store, previousState), withpreviousStatea plain object of the state before the tick. A function observer receives the changed map. A parent store marks the nested store's key as changed and joins the same tick. Replacing a nested store unsubscribes the old one.- Changes to timing and watcher order go into the changelog. The docs promise "next frame", they describe the microtask cycle instead.
Store lifecycle (#111) stays separate, it sits on subscribe and unsubscribe and does not touch the cycle.
Done when
- the three commented out tests in
test/unit/updates.test.jsare enabled and pass: the asynchronous update, one render with onebeforeUpdateand oneafterUpdatefor several sets, a property derived in a watcher rendered in the same cycle - a watcher runs once per changed property per cycle, with the first old and the last new value of the tick
- three sets on a store in one tick notify each observer once, element watchers for store properties receive the previous state, closes #91 and #108
await el.requestUpdate()resolves in a background tab and on an element that was disconnected in the meantime- the test suite of
element-js-ssr-rendererstays green on the dom-shim, no cycle runs on the server docs/features/watch.mdanddocs/features/store.mddescribe the cycle and the hook arguments
- 主要言語
- 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 日以内に返信