Constructor
new MutationDiffObserver(tracker, roots, filteropt, attributeFilteropt)
Construct a new observer and begin observing
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
tracker | MutationDiff | the MutationDiff object to attach to | ||
roots | Node | | a single or list of root nodes to observe | ||
filter | number | <optional> | ALL | A bitmask specifying which mutations to observe, such as character data, attribute, or child list changes. |
attributeFilter | Array.<string> | <optional> | An array of specific attribute names to watch. Ignored if the ATTRIBUTE flag is not included in |
- Source
Members
observer :MutationObserver
The internal MutationObserver
object that is observing root
- MutationObserver
- Source
options :Object
The observer options passed to MutationObserver.observe()
- Object
- Source
root :Array.<Node>
A list of root nodes that are being observed
- Array.<Node>
- Source
tracker :MutationDiff
The MutationDiff object that mutations are being reported to
- Source
Methods
flush(synchronizeopt)
Flush any pending MutationRecord
s so that MutationDiff is up-to-date. This is necessary because MutationObserver
is async and batched, so the records lag behind the actual DOM mutations.
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
synchronize | boolean | <optional> | true | Whether to call MutationDiff#synchronize after flushing the records |
- Source
reattach()
MutationObserver
will observe descendants of root, and continues observing those descendants even when they are moved to a different part of the DOM tree (see explanation on MDN). This method will reattach the MutationObserver
so that it is only observing the current descendants of root.
- Source
stop()
Stop the observer. You can call reattach to start observing again. Make sure to call stop
when you are done, otherwise the object will not get garbage collected!
- Source