docs/solutions/logic-errors/2026-04-09-slate-node-fragment-must-clone-and-prune-in-root-relative-space.md
Node.fragment(...) was missing entirely in slate-v2, even though the public
node API still described it.
Porting it naively is easy to fuck up:
Node.fragment(...) is a pure node-utility helper, not an editor transaction.
That means it has to work on any root ancestor and any range expressed relative to that root, without leaning on editor-only fragment helpers or runtime ids.
Use a clone-and-prune algorithm in root-relative space:
childrenNode.nodes(...) in reverse orderThe reverse walk matters because child removals would otherwise invalidate later paths still waiting to be processed.
The helper stays:
It also composes cleanly with the rest of the recovered Node.* traversal
surface, because the same path semantics drive both the walk and the pruning.
Node.fragment(...) as a node-utility operation, not an editor
transaction helper.