Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

Revision 1018234 of MutationRecord

  • Revision slug: Web/API/MutationRecord
  • Revision title: MutationRecord
  • Revision id: 1018234
  • Created:
  • Creator: cvrebert
  • Is current revision? No
  • Comment add Specifications section

Revision Content

A MutationRecord represents an individual DOM mutation. It is the object that is passed to {{domxref("MutationObserver")}}'s callback.

Properties

Property Type Description
{{domxref("MutationRecord.type")}} String Returns "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.
{{domxref("MutationRecord.target")}} {{domxref("Node")}}

Returns the node the mutation affected, depending on the {{domxref("MutationRecord.type")}}.

For attributes, it is the element whose attribute changed.

For characterData, it is the CharacterData node.

For childList, it is the node whose children changed.

{{domxref("MutationRecord.addedNodes")}} {{domxref("NodeList")}} Return the nodes added. Will be an empty {{domxref("NodeList")}} if no nodes were added.
{{domxref("MutationRecord.removedNodes")}} {{domxref("NodeList")}} Return the nodes removed. Will be an empty {{domxref("NodeList")}} if no nodes were removed.
{{domxref("MutationRecord.previousSibling")}} {{domxref("Node")}} Return the previous sibling of the added or removed nodes, or null.
{{domxref("MutationRecord.nextSibling")}} {{domxref("Node")}} Return the next sibling of the added or removed nodes, or null.
{{domxref("MutationRecord.attributeName")}} String Returns the local name of the changed attribute, or null.
{{domxref("MutationRecord.attributeNamespace")}} String Returns the namespace of the changed attribute, or null.
{{domxref("MutationRecord.oldValue")}} String

The return value depends on the {{domxref("MutationRecord.type")}}.

For attributes, 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.

Specifications

Specification Status Comment
{{SpecName('DOM WHATWG', '#mutationrecord', 'MutationRecord')}} {{ Spec2('DOM WHATWG') }}  
{{SpecName('DOM4', '#mutationrecord', 'MutationRecord')}} {{ Spec2('DOM4') }}  

Revision Source

<p>A <strong><code>MutationRecord</code></strong> represents an individual DOM mutation. It is the object that is passed to {{domxref("MutationObserver")}}'s callback.</p>

<h2 id="Properties">Properties</h2>

<table class="standard-table">
 <tbody>
  <tr>
   <td class="header">Property</td>
   <td class="header">Type</td>
   <td class="header">Description</td>
  </tr>
  <tr>
   <td>{{domxref("MutationRecord.type")}}</td>
   <td><code>String</code></td>
   <td>Returns <code>"attributes"</code> if the mutation was an attribute mutation,<br />
    <code>"characterData"</code> if it was a mutation to a <code>CharacterData</code> node,<br />
    and <code>"childList"</code> if it was a mutation to the tree of nodes.</td>
  </tr>
  <tr>
   <td>{{domxref("MutationRecord.target")}}</td>
   <td><code>{{domxref("Node")}}</code></td>
   <td>
    <p>Returns the node the mutation affected, depending on the {{domxref("MutationRecord.type")}}.</p>

    <p>For <code>attributes</code>, it is the element whose attribute changed.</p>

    <p>For <code>characterData</code>, it is the <code>CharacterData</code> node.</p>

    <p>For <code>childList</code>, it is the node whose children changed.</p>
   </td>
  </tr>
  <tr>
   <td>{{domxref("MutationRecord.addedNodes")}}</td>
   <td><code>{{domxref("NodeList")}}</code></td>
   <td>Return the nodes added. Will be an empty {{domxref("NodeList")}} if no nodes were added.</td>
  </tr>
  <tr>
   <td>{{domxref("MutationRecord.removedNodes")}}</td>
   <td><code>{{domxref("NodeList")}}</code></td>
   <td>Return the nodes removed. Will be an empty {{domxref("NodeList")}} if no nodes were removed.</td>
  </tr>
  <tr>
   <td>{{domxref("MutationRecord.previousSibling")}}</td>
   <td><code>{{domxref("Node")}}</code></td>
   <td>Return the previous sibling of the added or removed nodes, or <code>null</code>.</td>
  </tr>
  <tr>
   <td>{{domxref("MutationRecord.nextSibling")}}</td>
   <td><code>{{domxref("Node")}}</code></td>
   <td>Return the next sibling of the added or removed nodes, or <code>null</code>.</td>
  </tr>
  <tr>
   <td>{{domxref("MutationRecord.attributeName")}}</td>
   <td><code>String</code></td>
   <td>Returns the local name of the changed attribute, or <code>null</code>.</td>
  </tr>
  <tr>
   <td>{{domxref("MutationRecord.attributeNamespace")}}</td>
   <td><code>String</code></td>
   <td>Returns the namespace of the changed attribute, or <code>null</code>.</td>
  </tr>
  <tr>
   <td>{{domxref("MutationRecord.oldValue")}}</td>
   <td><code>String</code></td>
   <td>
    <p>The return value depends on the {{domxref("MutationRecord.type")}}.</p>

    <p>For <code>attributes</code>, it is the value of the changed attribute before the change.</p>

    <p>For <code>characterData</code>, it is the data of the changed node before the change.</p>

    <p>For <code>childList</code>, it is <code>null</code>.</p>
   </td>
  </tr>
 </tbody>
</table>

<h2 id="Specifications" name="Specifications">Specifications</h2>

<table class="standard-table">
 <thead>
  <tr>
   <th scope="col">Specification</th>
   <th scope="col">Status</th>
   <th scope="col">Comment</th>
  </tr>
 </thead>
 <tbody>
  <tr>
   <td>{{SpecName('DOM WHATWG', '#mutationrecord', 'MutationRecord')}}</td>
   <td>{{ Spec2('DOM WHATWG') }}</td>
   <td>&nbsp;</td>
  </tr>
  <tr>
   <td>{{SpecName('DOM4', '#mutationrecord', 'MutationRecord')}}</td>
   <td>{{ Spec2('DOM4') }}</td>
   <td>&nbsp;</td>
  </tr>
 </tbody>
</table>
Revert to this revision