# ally.observe.shadowMutations
Registers MutationObservers across nested ShadowRoots.
# Description
This service registers a MutationObserver so that all ShadowRoots 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
TypeErrorifcontextoption is not anHTMLElement.TypeErrorifcallbackoption is not specified or not afunction.TypeErrorifconfigoption is not specified or not anobject.
# Callback signature
The callback is invoked with one argument, an array of MutationRecords.
# 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.