MutationObserverInit

MutationObserverInit dictionary describes the configuration of a mutation observer. As such, it's primarily used as the type of the options parameter on the MutationObserver.observe() 方法。

特性

At a minimum, one of childList , attributes , and/or characterData 必须是 true when you call observe() . Otherwise, a TypeError exception will be thrown.

subtree 可选
Set to true to extend monitoring to the entire subtree of nodes rooted at target . All of the other MutationObserverInit properties are then extended to all of the nodes in the subtree instead of applying solely to the target node. The default value is false .
childList 可选
Set to true to monitor the target node (and, if subtree is true , its descendants) for the addition of new child nodes or removal of existing child nodes. The default value is false .
attributes 可选
Set to true to watch for changes to the value of attributes on the node or nodes being monitored. The default value is true if either of attributeFilter or attributeOldValue is specified, otherwise the default value is false .
attributeFilter 可选
An array of specific attribute names to be monitored. If this property isn't included, changes to all attributes cause mutation notifications.
attributeOldValue 可选
Set to true to record the previous value of any attribute that changes when monitoring the node or nodes for attribute changes; see Monitoring attribute values in MutationObserver for details on watching for attribute changes and value recording. The default value is false .
characterData 可选
Set to true to monitor the specified target node (and, if subtree is true , its descendants) for changes to the character data contained within the node or nodes. The default value is true if characterDataOldValue is specified, otherwise the default value is false .
characterDataOldValue 可选
Set to true to record the previous value of a node's text whenever the text changes on nodes being monitored. For details and an example, see Monitoring text content changes in MutationObserver 。默认值为 false .

规范

规范 状态 Comment
DOM
The definition of 'MutationObserverInit' in that specification.
实时标准

浏览器兼容性

更新 GitHub 上的兼容性数据
Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
MutationObserverInit Chrome 26
26
18 — 26
Prefixed
Prefixed Implemented with the vendor prefix: webkit
Edge 12 Firefox 14 IE 11 Opera 15 Safari 7
7
6 — 7
Prefixed
Prefixed Implemented with the vendor prefix: webkit
WebView Android ? Chrome Android 26
26
18 — 26
Prefixed
Prefixed Implemented with the vendor prefix: webkit
Firefox Android 14 Opera Android 14 Safari iOS 7
7
6 — 7
Prefixed
Prefixed Implemented with the vendor prefix: webkit
Samsung Internet Android 1.5
1.5
1.0 — 1.5
Prefixed
Prefixed Implemented with the vendor prefix: webkit
attributeFilter Chrome 26
26
18 — 26
Prefixed
Prefixed Implemented with the vendor prefix: webkit
Edge 12
注意事项
12
注意事项
Before Edge 79, this requires attributes: true 当使用 attributeFilter 。若 attributes: true is not present, then Edge throws a syntax error.
Firefox 14 IE 11
注意事项
11
注意事项
Internet Explorer requires attributes: true 当使用 attributeFilter 。若 attributes: true is not present, then Internet Explorer throws a syntax error.
Opera 15 Safari 7
7
6 — 7
Prefixed
Prefixed Implemented with the vendor prefix: webkit
WebView Android ? Chrome Android 26
26
18 — 26
Prefixed
Prefixed Implemented with the vendor prefix: webkit
Firefox Android 14 Opera Android 14 Safari iOS 7
7
6 — 7
Prefixed
Prefixed Implemented with the vendor prefix: webkit
Samsung Internet Android 1.5
1.5
1.0 — 1.5
Prefixed
Prefixed Implemented with the vendor prefix: webkit
attributeOldValue Chrome 26
26
18 — 26
Prefixed
Prefixed Implemented with the vendor prefix: webkit
Edge 12 Firefox 14
注意事项
14
注意事项
Starting in Firefox 36, attributeOldValue has no default value; previously, its default value was false .
IE 11 Opera 15 Safari 7
7
6 — 7
Prefixed
Prefixed Implemented with the vendor prefix: webkit
WebView Android ? Chrome Android 26
26
18 — 26
Prefixed
Prefixed Implemented with the vendor prefix: webkit
Firefox Android 14
注意事项
14
注意事项
Starting in Firefox 36, attributeOldValue has no default value; previously, its default value was false .
Opera Android 14 Safari iOS 7
7
6 — 7
Prefixed
Prefixed Implemented with the vendor prefix: webkit
Samsung Internet Android 1.5
1.5
1.0 — 1.5
Prefixed
Prefixed Implemented with the vendor prefix: webkit
attributes Chrome 26
26
18 — 26
Prefixed
Prefixed Implemented with the vendor prefix: webkit
Edge 12 Firefox 14
注意事项
14
注意事项
Starting in Firefox 36, attributes has no default value; previously, its default value was false .
IE 11 Opera 15 Safari 7
7
6 — 7
Prefixed
Prefixed Implemented with the vendor prefix: webkit
WebView Android ? Chrome Android 26
26
18 — 26
Prefixed
Prefixed Implemented with the vendor prefix: webkit
Firefox Android 14
注意事项
14
注意事项
Starting in Firefox 36, attributes has no default value; previously, its default value was false .
Opera Android 14 Safari iOS 7
7
6 — 7
Prefixed
Prefixed Implemented with the vendor prefix: webkit
Samsung Internet Android 1.5
1.5
1.0 — 1.5
Prefixed
Prefixed Implemented with the vendor prefix: webkit
characterData Chrome 26
26
18 — 26
Prefixed
Prefixed Implemented with the vendor prefix: webkit
Edge 12 Firefox 14
注意事项
14
注意事项
Starting in Firefox 36, characterData has no default value; previously, its default value was false .
IE 11 Opera 15 Safari 7
7
6 — 7
Prefixed
Prefixed Implemented with the vendor prefix: webkit
WebView Android ? Chrome Android 26
26
18 — 26
Prefixed
Prefixed Implemented with the vendor prefix: webkit
Firefox Android 14
注意事项
14
注意事项
Starting in Firefox 36, characterData has no default value; previously, its default value was false .
Opera Android 14 Safari iOS 7
7
6 — 7
Prefixed
Prefixed Implemented with the vendor prefix: webkit
Samsung Internet Android 1.5
1.5
1.0 — 1.5
Prefixed
Prefixed Implemented with the vendor prefix: webkit
characterDataOldValue Chrome 26
26
18 — 26
Prefixed
Prefixed Implemented with the vendor prefix: webkit
Edge 12 Firefox 14
注意事项
14
注意事项
Starting in Firefox 36, characterDataOldValue has no default value; previously, its default value was false .
IE 11 Opera 15 Safari 7
7
6 — 7
Prefixed
Prefixed Implemented with the vendor prefix: webkit
WebView Android ? Chrome Android 26
26
18 — 26
Prefixed
Prefixed Implemented with the vendor prefix: webkit
Firefox Android 14
注意事项
14
注意事项
Starting in Firefox 36, characterDataOldValue has no default value; previously, its default value was false .
Opera Android 14 Safari iOS 7
7
6 — 7
Prefixed
Prefixed Implemented with the vendor prefix: webkit
Samsung Internet Android 1.5
1.5
1.0 — 1.5
Prefixed
Prefixed Implemented with the vendor prefix: webkit
childList Chrome 26
26
18 — 26
Prefixed
Prefixed Implemented with the vendor prefix: webkit
Edge 12 Firefox 14 IE 11 Opera 15 Safari 7
7
6 — 7
Prefixed
Prefixed Implemented with the vendor prefix: webkit
WebView Android ? Chrome Android 26
26
18 — 26
Prefixed
Prefixed Implemented with the vendor prefix: webkit
Firefox Android 14 Opera Android 14 Safari iOS 7
7
6 — 7
Prefixed
Prefixed Implemented with the vendor prefix: webkit
Samsung Internet Android 1.5
1.5
1.0 — 1.5
Prefixed
Prefixed Implemented with the vendor prefix: webkit
subtree Chrome 26
26
18 — 26
Prefixed
Prefixed Implemented with the vendor prefix: webkit
Edge 12 Firefox 14 IE 11 Opera 15 Safari 7
7
6 — 7
Prefixed
Prefixed Implemented with the vendor prefix: webkit
WebView Android ? Chrome Android 26
26
18 — 26
Prefixed
Prefixed Implemented with the vendor prefix: webkit
Firefox Android 14 Opera Android 14 Safari iOS 7
7
6 — 7
Prefixed
Prefixed Implemented with the vendor prefix: webkit
Samsung Internet Android 1.5
1.5
1.0 — 1.5
Prefixed
Prefixed Implemented with the vendor prefix: webkit

图例

完整支持
完整支持
兼容性未知
兼容性未知
见实现注意事项。
要求使用供应商前缀或不同名称。
要求使用供应商前缀或不同名称。