From a85a030e78a5f87b31746e252d53eac0c2ea336a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Sun, 30 Aug 2026 21:09:05 +0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix(morph):=20the=20client=20say?= =?UTF-8?q?s=20what=20is=20its=20own,=20and=20the=20morph=20knows=20no=20n?= =?UTF-8?q?ames?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Saving one setting drew every dropdown twice: the styled trigger, and under it the native select it was built to replace. The live refresh morphs the server's HTML over the live DOM, and `syncAttrs` copied the server's `class` wholesale — wiping `dd-native`, which is the only thing hiding that select. `data-dd-done` survived, because it was on a hand-written exemption list, so `enhanceAll` skipped the select as already enhanced and never re-hid it. Half the enhancement survived, which is worse than none of it. The narrow fix would have been to add `class` to that list. The list is the defect: it is a fact about dropdowns kept in a file that must not know about dropdowns, and it is wrong the first time somebody adds an enhancement without reading it. So the morph now knows no names at all. A node declares what belongs to the client, at the moment the client takes it — `__izlekOwn(node, classes, attrs)` for marks on a server-rendered node, `__izlekAdded(node)` for a node the client built — recorded on a DOM property, which no morph can strip. `__izlekOwn` applies the classes itself, so there is no way to add one without registering it. Three more instances of the same class, found by looking for it: the audio player's `data-wired` (stripped, so a refresh stacked a second set of listeners on the same element), the card menu's `card-menu-open` and the inline `style` holding its position, and the user menu's `user-menu-esc`. Ownership stops the morph from breaking an enhancement. It does not make the enhancement follow the data, so `izlek:wire` is now a repair rather than an install: an already-enhanced select re-asserts `dd-native`, re-reads its label off the select, and rebuilds its rows when the options changed — an open panel is left alone, since moving rows under the pointer is worse than being stale for a moment. Without that, a status somebody else changed would morph underneath a trigger still announcing the old one. Verified in Chromium against a throwaway server: on the old build all four profile selects come back visible with `dd-native` gone after one save; on this one, zero visible natives and exactly one trigger each, across a save, eleven morphing refreshes and no console errors. --- crates/izlek-web/src/board.rs | 2 +- crates/izlek-web/src/detail.rs | 3 +- crates/izlek-web/src/dropdown.rs | 69 ++++++++++++++++++++++----- crates/izlek-web/src/layout.rs | 82 ++++++++++++++++++++++++++------ crates/izlek-web/tests/http.rs | 79 ++++++++++++++++++++++++++++++ 5 files changed, 206 insertions(+), 29 deletions(-) diff --git a/crates/izlek-web/src/board.rs b/crates/izlek-web/src/board.rs index 3f9ac70..7869b20 100644 --- a/crates/izlek-web/src/board.rs +++ b/crates/izlek-web/src/board.rs @@ -448,7 +448,7 @@ async fn card_menu_script(cx: &Cx) -> Result { if (!menu) { return; } \ menu.style.left = e.clientX + 'px'; \ menu.style.top = e.clientY + 'px'; \ - menu.classList.add('card-menu-open'); \ + window.__izlekOwn(menu, ['card-menu-open'], ['style']); \ }; \ document.addEventListener('click', closeCardMenus); \ window.__izlekEsc.register(20, function () { \ diff --git a/crates/izlek-web/src/detail.rs b/crates/izlek-web/src/detail.rs index fc243b0..a7108ca 100644 --- a/crates/izlek-web/src/detail.rs +++ b/crates/izlek-web/src/detail.rs @@ -2081,6 +2081,7 @@ async fn audio_player_script(cx: &Cx) -> Result { function wireAll() { document.querySelectorAll('.audio-player').forEach(wirePlayer); } \ function wirePlayer(player) { \ if (player.dataset.wired) { return; } \ + window.__izlekOwn(player, [], ['data-wired']); \ player.dataset.wired = '1'; \ var audio = player.querySelector('.audio-el'); \ var play = player.querySelector('.audio-play'); \ @@ -2097,7 +2098,7 @@ async fn audio_player_script(cx: &Cx) -> Result { if (audio.paused) { audio.play(); } else { audio.pause(); } \ }); \ audio.addEventListener('play', function () { \ - player.classList.add('audio-playing'); \ + window.__izlekOwn(player, ['audio-playing'], []); \ play.setAttribute('aria-label', play.getAttribute('data-pause')); \ }); \ audio.addEventListener('pause', function () { \ diff --git a/crates/izlek-web/src/dropdown.rs b/crates/izlek-web/src/dropdown.rs index 3db2770..95681f0 100644 --- a/crates/izlek-web/src/dropdown.rs +++ b/crates/izlek-web/src/dropdown.rs @@ -44,7 +44,16 @@ use topcoat::view::{Unescaped, view}; /// Emitted once per page that renders a `