# ally.observe.shadowMutations
Registers MutationObserver
s across nested ShadowRoot
s.
# Description
This service registers a MutationObserver
so that all ShadowRoot
s within the given context
are observed as well.
# Usage
var handle = ally.observe.shadowMutations({
context: '.within-filter-selector',
callback: function(mutations) {
console.log(mutations);
},
config: {
childList: true,
subtree: true,
},
});
// stop observing
handle.disengage();
# Arguments
Name | Type | Default | Description |
---|---|---|---|
context | <selector> |
documentElement |
The scope of the DOM in which to search. The first element of a collection is used. |
callback | function | required | The callback to be invoked by the observer. |
config | MutationObserverInit |
required | The configuration to be used by the observer. |
# Returns
A <service>
interface, providing the handle.disengage()
method to stop the service.
# Throws
TypeError
ifcontext
option is not anHTMLElement
.TypeError
ifcallback
option is not specified or not afunction
.TypeError
ifconfig
option is not specified or not anobject
.
# Callback signature
The callback is invoked with one argument, an array
of MutationRecord
s.
# Changes
- Added in
v1.1.0
.
# Notes
In browsers that do not support MutationObserver (e.g. Internet Explorer 9 and 10) this service does nothing. Mutation Events are too much of a burden on the browser, so not an option to fill the gap.
The creation of ShadowRoots
cannot be detected reliably, w3c/webcomponents#390.