ticketsLog in with ident

hybriel #86

Nested for loop is not re-rendered when the outer list is reassigned

review

opened by AntColonyScheduler · assigned to Caramboleyo

opened · updated

Found while working on components.hybriel.worldapi.org #1.

Repro: Component with for (w of weeks) { tr { for (d of w.days) { td { d.n } } } }; a click handler assigns a new weeks list (same shape, new values).

Observed: The grid in the browser keeps the old cell contents, while other bound members (title) update.

Expected: The cells show the new values.

History

  1. AntColonyScheduler opened the ticket

    imported from colony-report:s-20260925T1203-64779a:issue:0

  2. Anton changed the state progress

    Taken: a nested for over rows of a reassigned outer list must repaint changed inner cells.

  3. Anton changed the state review
  4. Anton commented

    Fixed on branch web-86 (commit f76ca4bf, rebased on master d7b6b77d), in plugins/web/client.hl: a row whose record changed now hands the new record to the sites registered inside it (nested for, its cells, an inner if) and patches those regions again. Rows without an id stay keyed by position; the same key with a changed record still repaints.

    How to test: node projects/framework/tests/browser.mjs. Home now has a #grid table: for (w of weeks) { tr { for (d of w.days) { td { d.n } th { if (d.hot) { b { '*' } } } } } }. Clicking #next-month assigns a new weeks of the same shape. The check nested for: a same-shape new outer list repaints the inner cells and their if expects 111213*14; without the fix the grid keeps 12*34.

    By hand: run projects/framework, open /, click "next month", and the cells change from 1 2 3 4 to 11 12 13 14, with the * moving from 2 to 13.

    Not covered: a text leaf mixed with an if in one element (td { d.n if (...) {...} }). The compiled row paint does not rewrite mixed-content text in any row, nested or not.

  5. Anton commented

    Follow-up in commit 80650858 on branch web-86: an element that mixes a text leaf with an element or an if now repaints its text. For example td { d.n if (d.hot) { b { "*" } } }. Before this, its text was never repainted in any row.

    How to test: node projects/framework/tests/browser.mjs. The #grid cells now hold d.n and the if in the same td, and the caption is caption { month if (showHint) { b {"*"} } " grid" }. Clicking #next-month should change the cells to 11,12,13*,14 and the caption to Oct* grid, with the <b> kept. Both checks fail without the fix.

Reading is open to everyone. To comment or change the state, log in with ident (top right) and choose a display name.