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 60019 of UserDataHandler

  • Revision slug: DOM/UserDataHandler
  • Revision title: UserDataHandler
  • Revision id: 60019
  • Created:
  • Creator: fscholz
  • Is current revision? No
  • Comment 123 words added, 16 words removed

Revision Content

{{ DomRef() }}

Summary

When associating user data with a key on a node, Node.setUserData() can also accept, in its third argument, a handler which will be called when the object is cloned, imported, deleted, renamed, or adopted. Per the specification, exceptions should not be thrown in a UserDataHandler. In both document.importNode() and Node.cloneNode(), although user data is not copied over, the handler will be called.

Properties

None

Methods

handle (operation, key, data, src, dst) (no return)

This method is a callback which will be called if a node is being cloned, imported, renamed and as well, if deleted or adopted.

  • operation (unsigned short) is an operation type integer (see below).
  • key (DOMString) is the user key.
  • data (DOMString) is the user data.
  • src (Node) is the source node (null if being deleted).
  • dst (Node) is the destination node (if any, or null).

Constants

Constant Value Operation
NODE_CLONED 1 Node.cloneNode()
NODE_IMPORTED 2 Document.importNode()
NODE_DELETED {{ unimplemented_inline("550400") }} 3  
NODE_RENAMED {{ unimplemented_inline() }} 4 Node.renameNode()
NODE_ADOPTED 5 Document.adoptNode()

(NODE_RENAMED is currently not supported since Node.renameNode() is not supported.)

Specification

DOM Level 3 Core: UserDataHandler

See also

Revision Source

<p>{{ DomRef() }}</p>
<h3>Summary</h3>
<p>When associating user data with a key on a node, <code><a class="internal" href="/En/DOM/Node.setUserData" title="En/DOM/Node.setUserData">Node.setUserData</a>()</code> can also accept, in its third argument, a handler which will be called when the object is cloned, imported, deleted, renamed, or adopted. Per the specification, exceptions should not be thrown in a <code>UserDataHandler</code>. In both <code><a class="internal" href="/en/DOM/document.importNode" title="En/DOM/document.importNode">document.importNode</a>()</code> and <code><a class="internal" href="/En/DOM/Node.cloneNode" title="En/DOM/Node.cloneNode">Node.cloneNode</a>()</code>, although user data is not copied over, the handler will be called.</p>
<h3>Properties</h3>
<p>None</p>
<h3>Methods</h3>
<p><code>handle (operation, key, data, src, dst)</code> (no return)</p>
<p>This method is a callback which will be called if a node is being cloned, imported, renamed and as well, if deleted or adopted.</p>
<ul> <li><code>operation</code> (unsigned short) is an operation type integer (see below).</li> <li><code>key</code> (DOMString) is the user key.</li> <li><code>data</code> (DOMString) is the user data.</li> <li><code>src</code> (Node) is the source node (<code>null</code> if being deleted).</li> <li><code>dst</code> (Node) is the destination node (if any, or <code>null</code>).</li>
</ul>
<h3>Constants</h3>
<table class="standard-table"> <tbody> <tr> <th>Constant</th> <th>Value</th> <th>Operation</th> </tr> <tr> <td><code>NODE_CLONED</code></td> <td>1</td> <td><code><a href="/En/DOM/Node.cloneNode" title="En/DOM/Node.cloneNode">Node.cloneNode</a>()</code></td> </tr> <tr> <td><code>NODE_IMPORTED</code></td> <td>2</td> <td><code><a href="/En/DOM/Document.importNode" title="En/DOM/Document.importNode">Document.importNode</a>()</code></td> </tr> <tr> <td><code>NODE_DELETED</code> {{ unimplemented_inline("550400") }}</td> <td>3</td> <td> </td> </tr> <tr> <td><code>NODE_RENAMED</code> {{ unimplemented_inline() }}</td> <td>4</td> <td><code><a href="/En/DOM/Node.renameNode" title="En/DOM/Node.renameNode">Node.renameNode</a>()</code></td> </tr> <tr> <td><code>NODE_ADOPTED</code></td> <td>5</td> <td><code><a href="/En/DOM/document.adoptNode" title="En/DOM/document.adoptNode">Document.adoptNode</a>()</code></td> </tr> </tbody>
</table>
<p>(<code>NODE_RENAMED</code> is currently not supported since <code><a href="/En/DOM/Node.renameNode" title="En/DOM/Node.renameNode">Node.renameNode</a>()</code> is not supported.)</p>
<h3>Specification</h3>
<p><a class=" external" href="https://www.w3.org/TR/DOM-Level-3-Core/core.html#UserDataHandler">DOM Level 3 Core: UserDataHandler</a></p>
<h3>See also</h3>
<ul> <li><a href="/En/DOM/DOMUserData" title="En/DOM/DOMUserData"><code>DOMUserData</code></a></li> <li><a href="/En/DOM/Node.getUserData" title="En/DOM/Node.getUserData"><code>Node.getUserData</code></a>, <a href="/En/DOM/Node.setUserData" title="En/DOM/Node.setUserData"><code>Node.setUserData</code></a></li>
</ul>
Revert to this revision