mirror of
https://github.com/Matysh/houseplan-card
synced 2026-10-07 23:19:14 +00:00
fix: the adoption bodies are no longer declared Lit properties (#520)
#500 gave `_serverCfg` and `_layout` prototype accessors but left them in
`static properties`. Lit marks such a property `wrapped` and, on the FIRST
update, force-writes it into `changedProperties` with an `undefined` old
value even though nobody assigned anything (`reactive-element.js:249-252`
and `:880-886`). `willUpdate` reads that as a config replacement, raises
`_cfgEpoch`, the memoized model key changes, and a 60-room house builds and
paints its model a second time: measured 19 update cycles, 4 builds and 4
epochs against 18 / 3 / 3 before #500, worth ~550 ms of `modelReadyMs` and
the same on `firstStableRenderMs` (3355 against a 3000 ceiling).
The declaration goes; the bodies stay reactive through the owner —
`_adoption` → `onBodyReplaced` → `requestUpdate(field, previous)` — which
needs no declaration: `getPropertyOptions` falls back to the default and
`changed.has('_serverCfg')` works as before. `noAccessor: true` would not
help, `wrapped` is set before that flag is read. The trap is written above
`static properties`, where someone would put the declaration back.
`cache.entries.cleanFloor` returns to 100 in both interaction budgets: the
120 entries were the extra epoch re-keying the per-room cache, not a
property of the design — the reasoning in 914e8402 was wrong.
Witness: test/config-adoption-ownership.test.mjs pins that neither body is
declared; the mutant `adoption-bodies-declared-reactive` puts the
declaration back and reddens it.
The boot diagnostics of the previous three commits touch four private
members, so they are declared in the performance contract: `_buildModel` and
`_cfgEpoch` outright (both exist in every supported comparison base), and the
adoption entry point as a current/legacy pair — #500 turned the private
`_adoptStructuralResponses` into the public `_adoptAuthoritative`, and an
undeclared rename would have the counter report zero adoptions instead of
failing.
The same commits carried a `node_modules` symlink: `.gitignore` had the
pattern with a trailing slash, which does not cover a symbolic link, and
`git add -A` in a sandbox worktree committed it. The link is removed and the
pattern loses the slash; a mutant run on this branch failed with `EEXIST` on
it.
Issue: #520
User-Visible: no
This commit is contained in:
+17
-2
@@ -2537,6 +2537,23 @@ export class HouseplanCard extends LitElement {
|
||||
private _holdTimer?: number;
|
||||
private _holdFired = false;
|
||||
|
||||
/**
|
||||
* #520: `_serverCfg` и `_layout` здесь НЕ объявляются, хотя они реактивны.
|
||||
*
|
||||
* С #500 их тела принадлежат `_adoption`, а карточка видит их через
|
||||
* собственные аксессоры прототипа. Lit на такое объявление ставит флаг
|
||||
* `wrapped` (`createProperty`) и на ПЕРВОМ обновлении принудительно кладёт
|
||||
* свойство в `changedProperties` со старым значением `undefined` — даже
|
||||
* если никто ничего не присваивал. `willUpdate` читает это как замену
|
||||
* конфига, поднимает `_cfgEpoch`, ключ памятки модели меняется, и большой
|
||||
* дом собирает и рисует модель второй раз: +550 мс до первого устойчивого
|
||||
* кадра (замерено против базы `a44fbd37`, 3 эпохи против 4).
|
||||
*
|
||||
* Реактивность даёт `_adoption` через `onBodyReplaced` → `requestUpdate`:
|
||||
* `requestUpdate` не требует объявления, `getPropertyOptions` возвращает
|
||||
* умолчание, и `changed.has('_serverCfg')` работает как прежде.
|
||||
* `noAccessor: true` не помогает — `wrapped` ставится до его проверки.
|
||||
*/
|
||||
static properties = {
|
||||
_tabDrag: { state: true },
|
||||
_hdrH: { state: true },
|
||||
@@ -2553,11 +2570,9 @@ export class HouseplanCard extends LitElement {
|
||||
narrow: { attribute: false },
|
||||
_config: { state: true },
|
||||
_space: { state: true },
|
||||
_layout: { state: true },
|
||||
_devices: { state: true },
|
||||
_selId: { state: true },
|
||||
_toast: { state: true },
|
||||
_serverCfg: { state: true },
|
||||
_mode: { state: true },
|
||||
_tool: { state: true },
|
||||
_wallDialog: { state: true },
|
||||
|
||||
Reference in New Issue
Block a user