DOM

DOM

Source

Each node has a registered observer list (a list of
zero or more registered observers), which is initially empty.

A registered observer consists of an observer (a MutationObserver object) and options (a MutationObserverInit dictionary).

A transient registered observer is a registered observer that also consists of a source (a registered observer).

Transient registered observers are used to track mutations within
a given node’s descendants after node has been removed so
they do not get lost when subtree is set to true on node’s parent.

MutationObserver

In all current engines.

Firefox14+Safari7+Chrome26+ Opera15+Edge79+ Edge (Legacy)12+IE11 Firefox for Android14+iOS Safari7+Chrome for Android26+Android WebView37+Samsung Internet1.5+Opera Mobile14+

MutationObserverInit/attributeFilter

In all current engines.

Firefox14+Safari6+Chrome18+ Opera15+Edge79+ Edge (Legacy)12+IE11 Firefox for Android14+iOS Safari6+Chrome for Android18+Android WebView37+Samsung Internet1.0+Opera Mobile14+

MutationObserverInit/attributeOldValue

In all current engines.

Firefox14+Safari6+Chrome18+ Opera15+Edge79+ Edge (Legacy)12+IE11 Firefox for Android14+iOS Safari6+Chrome for Android18+Android WebView37+Samsung Internet1.0+Opera Mobile14+

MutationObserverInit/attributes

In all current engines.

Firefox14+Safari6+Chrome18+ Opera15+Edge79+ Edge (Legacy)12+IE11 Firefox for Android14+iOS Safari6+Chrome for Android18+Android WebView37+Samsung Internet1.0+Opera Mobile14+

MutationObserverInit/characterData

In all current engines.

Firefox14+Safari6+Chrome18+ Opera15+Edge79+ Edge (Legacy)12+IE11 Firefox for Android14+iOS Safari6+Chrome for Android18+Android WebView37+Samsung Internet1.0+Opera Mobile14+

MutationObserverInit/characterDataOldValue

In all current engines.

Firefox14+Safari6+Chrome18+ Opera15+Edge79+ Edge (Legacy)12+IE11 Firefox for Android14+iOS Safari6+Chrome for Android18+Android WebView37+Samsung Internet1.0+Opera Mobile14+

MutationObserverInit/childList

In all current engines.

Firefox14+Safari6+Chrome18+ Opera15+Edge79+ Edge (Legacy)12+IE11 Firefox for Android14+iOS Safari6+Chrome for Android18+Android WebView37+Samsung Internet1.0+Opera Mobile14+

MutationObserverInit/subtree

In all current engines.

Firefox14+Safari6+Chrome18+ Opera15+Edge79+ Edge (Legacy)12+IE11 Firefox for Android14+iOS Safari6+Chrome for Android18+Android WebView37+Samsung Internet1.0+Opera Mobile14+

MutationObserverInit

In all current engines.

Firefox14+Safari7+Chrome26+ Opera15+Edge79+ Edge (Legacy)12+IE11 Firefox for Android14+iOS Safari7+Chrome for Android26+Android WebView37+Samsung Internet1.5+Opera Mobile14+


[Exposed=Window]
interface MutationObserver { ); , optional  = {}); undefined disconnect(); sequence<MutationRecord> takeRecords();
}; callback MutationCallback = , ); dictionary MutationObserverInit { boolean childList = false; boolean attributes; boolean characterData; boolean subtree = false; boolean attributeOldValue; boolean characterDataOldValue; sequence<DOMString> attributeFilter;
};

A MutationObserver object can be used to observe mutations to the tree of nodes.

Each MutationObserver object has these associated concepts:

  • A callback set on creation.
  • A node list (a list of nodes), which is initially empty.
  • A record queue (a queue of zero or more MutationRecord objects), which is initially empty.
observer = new MutationObserver(callback) Constructs a MutationObserver object and sets its callback to callback. The callback is invoked with a list of MutationRecord objects as first argument and the constructed MutationObserver object as second argument. It is invoked after nodes registered with the observe() method, are mutated. observer . observe(target, options) Instructs the user agent to observe a given target (a node) and report any mutations based on the criteria given by options (an object).

The options argument allows for setting mutation observation options via object members. These are the object members that can be used:

childList Set to true if mutations to target’s children are to be observed. attributes Set to true if mutations to target’s attributes are to be observed. Can be omitted if attributeOldValue or attributeFilter is specified. characterData Set to true if mutations to target’s data are to be observed. Can be omitted if characterDataOldValue is specified. subtree Set to true if mutations to not just target, but also target’s descendants are to be observed. attributeOldValue Set to true if attributes is true or omitted and target’s attribute value before the mutation needs to be recorded. characterDataOldValue Set to true if characterData is set to true or omitted and target’s data before the mutation needs to be recorded. attributeFilter Set to a list of attribute local names (without namespace) if not all attribute mutations need to be observed and attributes is true or omitted. observer . disconnect() Stops observer from observing any mutations. Until the observe() method is used again, observer’s callback will not be invoked. observer . takeRecords() Empties the record queue and returns what was in there.

Read Next page

Report Page