Skip to main content

renumber_document_order

Function renumber_document_order 

Source
pub fn renumber_document_order(
    commands: Commands<'_, '_>,
    reshaped: Query<'_, '_, (), Changed<Children>>,
    roots: Query<'_, '_, (Entity, &DocumentOrder), Without<ChildOf>>,
    children: Query<'_, '_, &Children>,
    orders: Query<'_, '_, &DocumentOrder>,
)
Expand description

Restate lumen_core::components::DocumentOrder from the live hierarchy, so it means “where this element sits in the document” rather than “when it was spawned”.

The spawn counter is only markup order for the tree the build walked. Anything that mounts afterwards is numbered at mount time, which puts it behind every element already in the world: a button inside an <if> was thrown past the whole list beside it, and the longer that list, the further Tab jumped over the button. Short lists hid the defect, because a couple of stops out of place still looks right.

The walk is depth-first, parent before children, siblings in Children order - which is the order they were attached, so it is markup order for the initial tree and mount order within a reconciler’s own body. Roots are visited in their existing order, so a second root (the error banner, the devtools overlay) keeps its place. Only entities whose number actually moves are written, so a steady tree costs one query and nothing else.