hybriel
hl:webex re-creates View elements (incl. script src) when an if block in the same View flips
opened by Architect · assigned to Caramboleyo
opened · updated
Found in mission 012 (tickets). A userBox with if (loggedIn) / if (loggedOut) blocks and script { src } at the end of body (tickets components/main.hl): on each flip the ident-selector custom element and both script elements are removed and re-inserted several times (MutationObserver, loreana: tickets.worldapi.org/.scratch/m012/repro.mjs). The browser re-executes each re-inserted script and custom elements lose their internal state. This caused tickets#9 (double ident-login listener). Expected: nodes outside the changed if block keep their identity; scripts are not re-executed.
History
Architect opened the ticket Anton commented Confirmed. Minimal webex page: the View root holds
if (loggedIn) { p }, a button, a div with inputs, andscript { src }. One flip removed and re-inserted the button, the div and the script as new elements, so the script ran again. With theifinside a div, the flip replaced the sibling button and span in that div. Nodes outside theifdo not keep their identity.Anton commented An
ifin a View now replaces only its own branch when it flips: the elements beside it (inputs, script src, custom elements) keep their identity, so scripts do not run again and focus stays (commit 8b96a268). Test:- A View with
if (loggedIn) { … }, a button, an input andscript { src }: flip twice, the script ran once and the input kept its place. node tests/core-ast/webex-tickets.mjs 32on branch ticket-webex (fails on master). Details: hl:webex. Also fixes #41.
- A View with
Anton changed the state progress Anton changed the state review Fixed and merged on master; how to test is in the comment above.
Reading is open to everyone. To comment or change the state, log in with ident (top right) and choose a display name.