Table of Contents

Class MutationObserver

Namespace
AngleSharp.Dom
Assembly
AngleSharp.dll

MutationObserver provides developers a way to react to changes in a DOM.

[DomName("MutationObserver")]
public sealed class MutationObserver
Inheritance
MutationObserver
Inherited Members
Extension Methods

Constructors

MutationObserver(MutationCallback)

Creates a new mutation observer with the provided callback.

[DomConstructor]
public MutationObserver(MutationCallback callback)

Parameters

callback MutationCallback

The callback to trigger.

Methods

Connect(INode, bool, bool, bool?, bool?, bool?, bool?, IEnumerable<string>?)

Registers the MutationObserver instance to receive notifications of DOM mutations on the specified node.

[DomName("observe")]
[DomInitDict(1, false)]
public void Connect(INode target, bool childList = false, bool subtree = false, bool? attributes = null, bool? characterData = null, bool? attributeOldValue = null, bool? characterDataOldValue = null, IEnumerable<string>? attributeFilter = null)

Parameters

target INode

The Node on which to observe DOM mutations.

childList bool

If additions and removals of the target node's child elements (including text nodes) are to be observed.

subtree bool

If mutations to not just target, but also target's descendants are to be observed.

attributes bool?

If mutations to target's attributes are to be observed.

characterData bool?

If mutations to target's data are to be observed.

attributeOldValue bool?

If attributes is set to true and target's attribute value before the mutation needs to be recorded.

characterDataOldValue bool?

If characterData is set to true and target's data before the mutation needs to be recorded.

attributeFilter IEnumerable<string>

The attributes to observe. If this is not set, then all attributes are being observed.

Disconnect()

Stops the MutationObserver instance from receiving notifications of DOM mutations. Until the observe() method is used again, observer's callback will not be invoked.

[DomName("disconnect")]
public void Disconnect()

Flush()

Empties the MutationObserver instance's record queue and returns what was in there.

[DomName("takeRecords")]
public IEnumerable<IMutationRecord> Flush()

Returns

IEnumerable<IMutationRecord>

Returns an Array of MutationRecords.