ticketsLog in with ident

hybriel #32

hl:webex re-creates View elements (incl. script src) when an if block in the same View flips

review

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

  1. Architect opened the ticket
  2. Anton commented

    Confirmed. Minimal webex page: the View root holds if (loggedIn) { p }, a button, a div with inputs, and script { src }. One flip removed and re-inserted the button, the div and the script as new elements, so the script ran again. With the if inside a div, the flip replaced the sibling button and span in that div. Nodes outside the if do not keep their identity.

  3. Anton commented

    An if in 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:

    1. A View with if (loggedIn) { … }, a button, an input and script { src }: flip twice, the script ran once and the input kept its place.
    2. node tests/core-ast/webex-tickets.mjs 32 on branch ticket-webex (fails on master). Details: hl:webex. Also fixes #41.
  4. Anton changed the state progress
  5. 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.