MutationRecord

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.

MutationRecord は、 DOM に生じた個々の変更を表します。これは MutationObserver のコールバック関数に渡されるオブジェクトです。

プロパティ

プロパティ 意味
MutationRecord.type String 属性値の変更の場合は "attributes"CharacterData ノードに対する変更の場合は "characterData"、ノードのツリーに対する変更の場合は "childList" を返します。
MutationRecord.target Node 変更の影響を受けたノードを、 MutationRecord.type に応じて返します。
attributes の場合、属性が変更された要素となります。
characterData の場合、CharacterData ノードとなります。
childList の場合、子ノードが変更されたノードとなります。
MutationRecord.addedNodes NodeList 追加されたノードを返します。何もノードが追加されていなかった場合は、空の NodeList を返します。
MutationRecord.removedNodes NodeList 削除されたノードを返します。何もノードが削除されていなかった場合は、空の NodeList を返します。
MutationRecord.previousSibling Node 追加あるいは削除されたノードの直前にあるノード、もしくは null を返します。
MutationRecord.nextSibling Node 追加あるいは削除されたノードの直後にあるノード、もしくは null を返します。
MutationRecord.attributeName String 変更された属性のローカル名、もしくは null を返します。
MutationRecord.attributeNamespace String 変更された属性の名前空間、もしくは null を返します。
MutationRecord.oldValue String

返値は MutationRecord.type に応じて以下のように変わります。
attributes の場合、変更された属性の変更前の属性値となります。
characterData の場合、変更されたノードの変更前のデータとなります。
childList の場合、null となります。

なお、この機能が正常に動作するためには、 MutationObserver observe メソッドの対応する MutationObserverInit 引数で、 attributeOldValue または characterDataOldValuetrue に設定されている必要があります

仕様書

Specification
DOM
# interface-mutationrecord

ブラウザーの互換性

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
MutationRecord
addedNodes
attributeName
attributeNamespace
nextSibling
oldValue
previousSibling
removedNodes
target
type

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support