#[non_exhaustive]pub enum Mutation {
AttributeChanged {
id: NodeId,
name: String,
old: Option<String>,
new: Option<String>,
},
ClassChanged {
id: NodeId,
added: Vec<String>,
removed: Vec<String>,
},
ChildListChanged {
parent: NodeId,
added: Vec<NodeId>,
removed: Vec<NodeId>,
},
CharacterDataChanged {
id: NodeId,
old: String,
new: String,
},
InteractionChanged {
prev: Option<NodeId>,
next: Option<NodeId>,
kind: InteractionKind,
},
SelectionChanged {
prev: Option<Selection>,
next: Option<Selection>,
},
PreDetach {
detached_root: NodeId,
focused: Option<NodeId>,
hovered: Option<NodeId>,
},
}Expand description
One DOM mutation notification.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
AttributeChanged
set_attribute / remove_attribute / toggle_attribute.
old == None && new.is_some() → attribute added.
old.is_some() && new == None → attribute removed.
Both Some → value changed.
ClassChanged
One class was added or removed. add_class / remove_class /
toggle_class each fire a single record with one entry in
either added or removed; replace_class fires once with
both populated.
ChildListChanged
A parent’s child list was mutated. Fires once per top-level
operation — e.g. append_child(parent, frag) where frag has
three children fires three records, one per unwrapped child.
CharacterDataChanged
Text or Comment node data changed.
InteractionChanged
Hovered or focused node changed. Both prev and next may be
Some (re-pointed), either may be None (cleared or set-from-
nothing). The cascade dirty-tracker uses this to invalidate
both sides’ subtrees for :hover / :focus re-matching.
SelectionChanged
Document selection changed via Dom::set_selection. Either
prev or next may be None; cleared selections fire
next: None. Paint observers use this to invalidate the
::selection overlay on the nodes whose range changed.
PreDetach
About to detach — fired in detach_from_parent BEFORE
the structural unlink, so observers can dispatch implicit
blur / focusout / mouseleave / mouseout events
while the tree is still intact (the focused/hovered node’s
parent_node() still walks the live ancestor chain).
focused is Some(id) iff dom.focused() was inside the
subtree rooted at detached_root at the moment of detach.
hovered likewise for hover. If neither is set, no
PreDetach record is emitted (the structurally-cheap
short-circuit path in purge_interaction_state_for_subtree
also gates this record’s emission).
The subsequent InteractionChanged { next: None, kind }
records still fire from the purge step — observers that
only care about the post-detach state can listen to those.
PreDetach is for observers that need to dispatch real
DOM events with bubbling intact.