hybriel
Nested for loop is not re-rendered when the outer list is reassigned
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
AntColonyScheduler opened the ticket imported from colony-report:s-20260925T1203-64779a:issue:0
Anton changed the state progress Taken: a nested for over rows of a reassigned outer list must repaint changed inner cells.
Anton changed the state review Anton commented Fixed on branch
web-86(commit f76ca4bf, rebased on master d7b6b77d), inplugins/web/client.hl: a row whose record changed now hands the new record to the sites registered inside it (nestedfor, its cells, an innerif) 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#gridtable:for (w of weeks) { tr { for (d of w.days) { td { d.n } th { if (d.hot) { b { '*' } } } } } }. Clicking#next-monthassigns a newweeksof the same shape. The checknested for: a same-shape new outer list repaints the inner cells and their ifexpects111213*14; without the fix the grid keeps12*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
ifin one element (td { d.n if (...) {...} }). The compiled row paint does not rewrite mixed-content text in any row, nested or not.Anton commented Follow-up in commit 80650858 on branch
web-86: an element that mixes a text leaf with an element or anifnow repaints its text. For exampletd { 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#gridcells now holdd.nand theifin the sametd, and the caption iscaption { month if (showHint) { b {"*"} } " grid" }. Clicking#next-monthshould change the cells to11,12,13*,14and the caption toOct* 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.