UserDataHandler - Web APIs 编辑

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, or null).

Constants

ConstantValueOperation
NODE_CLONED1Node.cloneNode()
NODE_IMPORTED2Document.importNode()
NODE_DELETED Unimplemented (see bug 550400)3 
NODE_RENAMED Unimplemented4Node.renameNode()
NODE_ADOPTED5Document.adoptNode()

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

Specifications

DOM Level 3 Core: UserDataHandler

Browser compatibility

BCD tables only load in the browser

See also

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据

词条统计

浏览:50 次

字数:4120

最后编辑:7 年前

编辑次数:0 次

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文