Severity: high · Category: implementation bug
Evidence. __morphChildren (entry-generators.ts): id-paired nodes are morphed in place and never moved; remaining new nodes are appendChild-ed at the tail. A reordered id-keyed list (a,b → b,a) ends up in the wrong DOM order. Related (round-2 mid-4): the structural pass uses a hardcoded lookahead window of 4 with deletion inside the window, so >4 consecutive insertions cause old nodes to be deleted/recreated (state loss), and the window is undocumented.
Fix. Rewrite __morphChildren as an ordered walk: index old children by id; for each new child in order, match by id else structural scan FORWARD from the reference point (id'd old nodes are only consumed by id match); morph the match and MOVE it into position (insertBefore(o, ref) — moves preserve shadow roots and state); insert unmatched new nodes in place (with DSD instantiation, see H4); remove only old nodes never matched (no window, deletion is exact).
Acceptance. e2e: a reversed id-keyed list keeps both order and island state; a >4-row insertion batch preserves existing islands.
Filed from the 0.42 round-2 review (docs/audit/2026-07-28-alpha5-round2-review.md). Target line: 0.42.0-alpha.6.
Severity: high · Category: implementation bug
Evidence.
__morphChildren(entry-generators.ts): id-paired nodes are morphed in place and never moved; remaining new nodes areappendChild-ed at the tail. A reordered id-keyed list (a,b → b,a) ends up in the wrong DOM order. Related (round-2 mid-4): the structural pass uses a hardcoded lookahead window of 4 with deletion inside the window, so >4 consecutive insertions cause old nodes to be deleted/recreated (state loss), and the window is undocumented.Fix. Rewrite
__morphChildrenas an ordered walk: index old children by id; for each new child in order, match by id else structural scan FORWARD from the reference point (id'd old nodes are only consumed by id match); morph the match and MOVE it into position (insertBefore(o, ref)— moves preserve shadow roots and state); insert unmatched new nodes in place (with DSD instantiation, see H4); remove only old nodes never matched (no window, deletion is exact).Acceptance. e2e: a reversed id-keyed list keeps both order and island state; a >4-row insertion batch preserves existing islands.
Filed from the 0.42 round-2 review (docs/audit/2026-07-28-alpha5-round2-review.md). Target line: 0.42.0-alpha.6.