Obsolete since Gecko 26 (Firefox 26 / Thunderbird 26 / SeaMonkey 2.23 / Firefox OS 1.2)This feature is obsolete. Although it may still work in some browsers, its use is discouraged since it could be removed at any time. Try to avoid using it.
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 value)
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
(DOMUserData
) is the user data.src
(Node
) is the source node (null
if being deleted).dst
(Node
) is the destination node (if any, ornull
).
Constants
Constant | Value | Operation |
NODE_CLONED
|
1 | Node.cloneNode()
|
NODE_IMPORTED
|
2 | Document.importNode()
|
NODE_DELETED Unimplemented (see bug 550400)
|
3 | |
NODE_RENAMED Unimplemented
|
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
Browser compatibility
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
Update compatibility data on GitHub
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Chrome
No support No |
Edge
No support No |
Firefox
No support 4 — 22 |
IE
No support No |
Opera
No support No |
Safari
No support No |
WebView Android
No support No |
Chrome Android
No support No |
Firefox Android
No support 4 — 22 |
Opera Android
No support No |
Safari iOS
No support No |
Samsung Internet Android
No support No |
Chrome
No support No |
Edge
No support No |
Firefox
No support 4 — 22 |
IE
No support No |
Opera
No support No |
Safari
No support No |
WebView Android
No support No |
Chrome Android
No support No |
Firefox Android
No support 4 — 22 |
Opera Android
No support No |
Safari iOS
No support No |
Samsung Internet Android
No support No |
Legend
- No support
- No support
- Non-standard. Expect poor cross-browser support.'
- Non-standard. Expect poor cross-browser support.
- Deprecated. Not for use in new websites.'
- Deprecated. Not for use in new websites.
See also
UserDataHandler by Mozilla Contributors is licensed under CC-BY-SA 2.5.