pub struct MutationObserver(/* private fields */);Expand description
Provides a way to receive notifications about changes to the DOM.
Implementations§
Source§impl MutationObserver
impl MutationObserver
Sourcepub fn new<F>(callback: F) -> MutationObserverHandle
pub fn new<F>(callback: F) -> MutationObserverHandle
Returns a new MutationObserverHandle with the given callback.
The callback will be called with the following arguments when the observed DOM nodes change:
-
A vector of changes to the observed DOM nodes.
-
The
MutationObserver.
Sourcepub fn observe<T: INode>(
&self,
target: &T,
options: MutationObserverInit<'_>,
) -> Result<(), TODO>
pub fn observe<T: INode>( &self, target: &T, options: MutationObserverInit<'_>, ) -> Result<(), TODO>
Starts observing changes to the target.
When the target is changed, the MutationObserver is notified with a vector of MutationRecord.
The options specifies which changes should be observed.
Multiple different targets can be observed simultaneously (with the same or different options).
If you call observe on the same target multiple times, it will replace the old options
with the new options. It will not notify multiple times for the same change to the same
target.
§Panics
-
At least one of
child_list,attributes, orcharacter_datamust betrue. -
If
attribute_old_valueistrue, thenattributesmust betrue. -
If
character_data_old_valueistrue, thencharacter_datamust betrue. -
If
attribute_filterisSome, thenattributesmust betrue.
Sourcepub fn disconnect(&self)
pub fn disconnect(&self)
Stops observing all targets.
Until the observe method is called again,
the MutationObserver will not be notified of any changes.
Sourcepub fn take_records(&self) -> Vec<MutationRecord>
pub fn take_records(&self) -> Vec<MutationRecord>
Empties the MutationObserver’s record queue and returns what was in there.
This method is generally not needed, instead use the MutationObserver
callback to respond to changes.
Trait Implementations§
Source§impl AsRef<Reference> for MutationObserver
impl AsRef<Reference> for MutationObserver
Source§impl Clone for MutationObserver
impl Clone for MutationObserver
Source§fn clone(&self) -> MutationObserver
fn clone(&self) -> MutationObserver
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more