A
MutationRecord
represents an individual DOM mutation. It is the object that is passed to
MutationObserver
's callback.
| 特性 | 类型 | 描述 |
MutationRecord.type
|
字符串
|
返回
"attributes"
if the mutation was an attribute mutation,
"characterData"
if it was a mutation to a
CharacterData
node,
and
"childList"
if it was a mutation to the tree of nodes.
|
MutationRecord.target
|
节点
|
Returns the node the mutation affected, depending on the
MutationRecord.type
.
For
属性
, it is the element whose attribute changed.
For
characterData
, it is the
CharacterData
节点。
For
childList
, it is the node whose children changed.
|
MutationRecord.addedNodes
|
NodeList
|
Return the nodes added. Will be an empty
NodeList
if no nodes were added.
|
MutationRecord.removedNodes
|
NodeList
|
Return the nodes removed. Will be an empty
NodeList
if no nodes were removed.
|
MutationRecord.previousSibling
|
节点
|
Return the previous sibling of the added or removed nodes, or
null
.
|
MutationRecord.nextSibling
|
节点
|
Return the next sibling of the added or removed nodes, or
null
.
|
MutationRecord.attributeName
|
字符串
|
Returns the local name of the changed attribute, or
null
.
|
MutationRecord.attributeNamespace
|
字符串
|
Returns the namespace of the changed attribute, or
null
.
|
MutationRecord.oldValue
|
字符串
|
The return value depends on the
MutationRecord.type
.
For
属性
, it is the value of the changed attribute before the change.
For
characterData
, it is the data of the changed node before the change.
For
childList
, it is
null
.
Note that for this to work as expected,
|
| 规范 | 状态 | 注释 |
|---|---|---|
|
DOM
The definition of 'MutationRecord' in that specification. |
实时标准 |
| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
MutationRecord
|
Chrome Yes | Edge ≤18 | Firefox Yes | IE ? | Opera Yes | Safari Yes | WebView Android Yes | Chrome Android Yes | Firefox Android Yes | Opera Android Yes | Safari iOS Yes | Samsung Internet Android Yes |
addedNodes
|
Chrome Yes | Edge 12 | Firefox Yes | IE ? | Opera Yes | Safari Yes | WebView Android Yes | Chrome Android Yes | Firefox Android Yes | Opera Android Yes | Safari iOS Yes | Samsung Internet Android Yes |
attributeName
|
Chrome Yes | Edge ≤18 | Firefox Yes | IE ? | Opera Yes | Safari Yes | WebView Android Yes | Chrome Android Yes | Firefox Android Yes | Opera Android Yes | Safari iOS Yes | Samsung Internet Android Yes |
attributeNamespace
|
Chrome Yes | Edge ≤18 | Firefox Yes | IE ? | Opera Yes | Safari Yes | WebView Android Yes | Chrome Android Yes | Firefox Android Yes | Opera Android Yes | Safari iOS Yes | Samsung Internet Android Yes |
nextSibling
|
Chrome Yes | Edge ≤18 | Firefox Yes | IE ? | Opera Yes | Safari Yes | WebView Android Yes | Chrome Android Yes | Firefox Android Yes | Opera Android Yes | Safari iOS Yes | Samsung Internet Android Yes |
oldValue
|
Chrome Yes | Edge ≤18 | Firefox Yes | IE ? | Opera Yes | Safari Yes | WebView Android Yes | Chrome Android Yes | Firefox Android Yes | Opera Android Yes | Safari iOS Yes | Samsung Internet Android Yes |
previousSibling
|
Chrome Yes | Edge 12 | Firefox Yes | IE ? | Opera Yes | Safari Yes | WebView Android Yes | Chrome Android Yes | Firefox Android Yes | Opera Android Yes | Safari iOS Yes | Samsung Internet Android Yes |
removedNodes
|
Chrome Yes | Edge 12 | Firefox Yes | IE ? | Opera Yes | Safari Yes | WebView Android Yes | Chrome Android Yes | Firefox Android Yes | Opera Android Yes | Safari iOS Yes | Samsung Internet Android Yes |
target
|
Chrome Yes | Edge 12 | Firefox Yes | IE ? | Opera Yes | Safari Yes | WebView Android Yes | Chrome Android Yes | Firefox Android Yes | Opera Android Yes | Safari iOS Yes | Samsung Internet Android Yes |
type
|
Chrome Yes | Edge 12 | Firefox Yes | IE ? | Opera Yes | Safari Yes | WebView Android Yes | Chrome Android Yes | Firefox Android Yes | Opera Android Yes | Safari iOS Yes | Samsung Internet Android Yes |
完整支持
兼容性未知
MutationRecord
AbortController
AbortSignal
AbstractRange
Attr
ByteString
CDATASection
CSSPrimitiveValue
CSSValue
CSSValueList
CharacterData
ChildNode
注释
CustomEvent
DOMConfiguration
DOMError
DOMErrorHandler
DOMException
DOMImplementation
DOMImplementationList
DOMImplementationRegistry
DOMImplementationSource
DOMLocator
DOMObject
DOMParser
DOMPoint
DOMPointInit
DOMPointReadOnly
DOMRect
DOMString
DOMTimeStamp
DOMTokenList
DOMUserData
Document
DocumentFragment
DocumentType
元素
ElementTraversal
Entity
EntityReference
事件
EventTarget
HTMLCollection
MutationObserver
节点
NodeFilter
NodeIterator
NodeList
NonDocumentTypeChildNode
ProcessingInstruction
PromiseResolver
范围
StaticRange
文本
TextDecoder
TextEncoder
TimeRanges
TreeWalker
TypeInfo
USVString
UserDataHandler
XMLDocument