MutationObserverInit

MutationObserverInit字典描述了MutationObserver的配置。因此,它主要用作MutationObserver.observe()方法的参数类型。

属性

当你调用observe()方法时,childListattributes或者characterData中至少有一个必须为true,否则将抛出TypeError异常。

attributeFilter 可选
要监视的特定属性名称的数组。如果未包含此属性,则对所有属性的更改都会触发变动通知。无默认值。
attributeOldValue 可选
当监视节点的属性改动时,将此属性设为true 将记录任何有改动的属性的上一个值。有关观察属性更改和值记录的详细信息,详见Monitoring attribute values in MutationObserver。无默认值。
attributes 可选
设为true以观察受监视元素的属性值变更。默认值为false
characterData 可选
设为true以监视指定目标节点或子节点树中节点所包含的字符数据的变化。无默认值。
characterDataOldValue 可选
设为true以在文本在受监视节点上发生更改时记录节点文本的先前值。详情及例子,请查看Monitoring text content changes in MutationObserver。无默认值。
childList 可选
设为true以监视目标节点(如果subtreetrue,则包含子孙节点)添加或删除新的子节点。默认值为false
subtree 可选
设为true以扩展监视范围到目标节点下的整个子树的所有节点。MutationObserverInit的其他值都会作用于此子树下的所有节点,而不仅仅只作用于目标节点。默认值为false

规范

规范 状态 批注
DOM
MutationObserverInit
Living Standard  

浏览器兼容性

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidEdge MobileFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
MutationObserverInitChrome Full support 26
Full support 26
No support 18 — 26
Prefixed
Prefixed Implemented with the vendor prefix: webkit
Edge Full support YesFirefox Full support 14IE Full support 11Opera Full support 15Safari Full support 7
Full support 7
No support 6 — 7
Prefixed
Prefixed Implemented with the vendor prefix: webkit
WebView Android ? Chrome Android Full support 26
Full support 26
No support 18 — 26
Prefixed
Prefixed Implemented with the vendor prefix: webkit
Edge Mobile ? Firefox Android Full support 14Opera Android Full support 14Safari iOS Full support 7
Full support 7
No support 6 — 7
Prefixed
Prefixed Implemented with the vendor prefix: webkit
Samsung Internet Android ?
attributeFilterChrome Full support 26
Full support 26
No support 18 — 26
Prefixed
Prefixed Implemented with the vendor prefix: webkit
Edge Full support YesFirefox Full support 14IE Full support 11Opera Full support 15Safari Full support 7
Full support 7
No support 6 — 7
Prefixed
Prefixed Implemented with the vendor prefix: webkit
WebView Android ? Chrome Android Full support 26
Full support 26
No support 18 — 26
Prefixed
Prefixed Implemented with the vendor prefix: webkit
Edge Mobile ? Firefox Android Full support 14Opera Android Full support 14Safari iOS Full support 7
Full support 7
No support 6 — 7
Prefixed
Prefixed Implemented with the vendor prefix: webkit
Samsung Internet Android ?
attributeOldValueChrome Full support 26
Full support 26
No support 18 — 26
Prefixed
Prefixed Implemented with the vendor prefix: webkit
Edge Full support YesFirefox Full support 14
Notes
Full support 14
Notes
Notes Starting in Firefox 36, attributeOldValue has no default value; previously, its default value was false.
IE Full support 11Opera Full support 15Safari Full support 7
Full support 7
No support 6 — 7
Prefixed
Prefixed Implemented with the vendor prefix: webkit
WebView Android ? Chrome Android Full support 26
Full support 26
No support 18 — 26
Prefixed
Prefixed Implemented with the vendor prefix: webkit
Edge Mobile ? Firefox Android Full support 14
Notes
Full support 14
Notes
Notes Starting in Firefox 36, attributeOldValue has no default value; previously, its default value was false.
Opera Android Full support 14Safari iOS Full support 7
Full support 7
No support 6 — 7
Prefixed
Prefixed Implemented with the vendor prefix: webkit
Samsung Internet Android ?
attributesChrome Full support 26
Full support 26
No support 18 — 26
Prefixed
Prefixed Implemented with the vendor prefix: webkit
Edge Full support YesFirefox Full support 14
Notes
Full support 14
Notes
Notes Starting in Firefox 36, attributes has no default value; previously, its default value was false.
IE Full support 11Opera Full support 15Safari Full support 7
Full support 7
No support 6 — 7
Prefixed
Prefixed Implemented with the vendor prefix: webkit
WebView Android ? Chrome Android Full support 26
Full support 26
No support 18 — 26
Prefixed
Prefixed Implemented with the vendor prefix: webkit
Edge Mobile ? Firefox Android Full support 14
Notes
Full support 14
Notes
Notes Starting in Firefox 36, attributes has no default value; previously, its default value was false.
Opera Android Full support 14Safari iOS Full support 7
Full support 7
No support 6 — 7
Prefixed
Prefixed Implemented with the vendor prefix: webkit
Samsung Internet Android ?
characterDataChrome Full support 26
Full support 26
No support 18 — 26
Prefixed
Prefixed Implemented with the vendor prefix: webkit
Edge Full support YesFirefox Full support 14
Notes
Full support 14
Notes
Notes Starting in Firefox 36, characterData has no default value; previously, its default value was false.
IE Full support 11Opera Full support 15Safari Full support 7
Full support 7
No support 6 — 7
Prefixed
Prefixed Implemented with the vendor prefix: webkit
WebView Android ? Chrome Android Full support 26
Full support 26
No support 18 — 26
Prefixed
Prefixed Implemented with the vendor prefix: webkit
Edge Mobile ? Firefox Android Full support 14
Notes
Full support 14
Notes
Notes Starting in Firefox 36, characterData has no default value; previously, its default value was false.
Opera Android Full support 14Safari iOS Full support 7
Full support 7
No support 6 — 7
Prefixed
Prefixed Implemented with the vendor prefix: webkit
Samsung Internet Android ?
characterDataOldValueChrome Full support 26
Full support 26
No support 18 — 26
Prefixed
Prefixed Implemented with the vendor prefix: webkit
Edge Full support YesFirefox Full support 14
Notes
Full support 14
Notes
Notes Starting in Firefox 36, characterDataOldValue has no default value; previously, its default value was false.
IE Full support 11Opera Full support 15Safari Full support 7
Full support 7
No support 6 — 7
Prefixed
Prefixed Implemented with the vendor prefix: webkit
WebView Android ? Chrome Android Full support 26
Full support 26
No support 18 — 26
Prefixed
Prefixed Implemented with the vendor prefix: webkit
Edge Mobile ? Firefox Android Full support 14
Notes
Full support 14
Notes
Notes Starting in Firefox 36, characterDataOldValue has no default value; previously, its default value was false.
Opera Android Full support 14Safari iOS Full support 7
Full support 7
No support 6 — 7
Prefixed
Prefixed Implemented with the vendor prefix: webkit
Samsung Internet Android ?
childListChrome Full support 26
Full support 26
No support 18 — 26
Prefixed
Prefixed Implemented with the vendor prefix: webkit
Edge Full support YesFirefox Full support 14IE Full support 11Opera Full support 15Safari Full support 7
Full support 7
No support 6 — 7
Prefixed
Prefixed Implemented with the vendor prefix: webkit
WebView Android ? Chrome Android Full support 26
Full support 26
No support 18 — 26
Prefixed
Prefixed Implemented with the vendor prefix: webkit
Edge Mobile ? Firefox Android Full support 14Opera Android Full support 14Safari iOS Full support 7
Full support 7
No support 6 — 7
Prefixed
Prefixed Implemented with the vendor prefix: webkit
Samsung Internet Android ?
subtreeChrome Full support 26
Full support 26
No support 18 — 26
Prefixed
Prefixed Implemented with the vendor prefix: webkit
Edge Full support YesFirefox Full support 14IE Full support 11Opera Full support 15Safari Full support 7
Full support 7
No support 6 — 7
Prefixed
Prefixed Implemented with the vendor prefix: webkit
WebView Android ? Chrome Android Full support 26
Full support 26
No support 18 — 26
Prefixed
Prefixed Implemented with the vendor prefix: webkit
Edge Mobile ? Firefox Android Full support 14Opera Android Full support 14Safari iOS Full support 7
Full support 7
No support 6 — 7
Prefixed
Prefixed Implemented with the vendor prefix: webkit
Samsung Internet Android ?

Legend

Full support  
Full support
Compatibility unknown  
Compatibility unknown
See implementation notes.
See implementation notes.
Requires a vendor prefix or different name for use.
Requires a vendor prefix or different name for use.

文档标签和贡献者

此页面的贡献者: mdnwebdocs-bot, Y____C
最后编辑者: mdnwebdocs-bot,