Bug 39699 - Implement DOM Level 3 Node::getUserData/setUserData
Summary: Implement DOM Level 3 Node::getUserData/setUserData
Status: RESOLVED INVALID
Alias: None
Product: WebKit
Classification: Unclassified
Component: DOM (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-05-25 16:36 PDT by kangax
Modified: 2023-08-26 01:08 PDT (History)
7 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description kangax 2010-05-25 16:36:08 PDT
DOM Level 3 is currently draft, but `Node::getUserData` (http://www.w3.org/TR/DOM-Level-3-Core/core.html#Node3-getUserData )/`Node::setUserData` (http://www.w3.org/TR/DOM-Level-3-Core/core.html#Node3-setUserData ) are already implemented in Mozilla and are a convenient way to store user data for node (instead of assigning expandos).
Comment 1 Sam Weinig 2010-11-11 08:05:51 PST
How does using userData differ from using expandos?  Why would one want to use use it rather than an expando?
Comment 2 kangax 2010-11-11 08:22:08 PST
The problem with expandos is collisions with members of any interfaces implemented by a node in question. How can you have a data under a key of "nodeName", "appendChild", etc. In implementations that make DOM objects inherit from Object.prototype or Function.prototype (such as webkit) there's additional set of candidates for collisions (toString, constructor, call, etc.).
Comment 3 Anne van Kesteren 2010-11-11 08:31:41 PST
If the problem is collisions we should do something much simpler than UserData imo. (Note that UserData is tentatively removed from Web DOM Core.)
Comment 4 kangax 2010-11-11 08:59:00 PST
(In reply to comment #3)
> If the problem is collisions we should do something much simpler than UserData imo. (Note that UserData is tentatively removed from Web DOM Core.)

Ok. But simpler how? I can imagine something like `Node::userData` (shorter name + no function call) where `userData` would need to be explicitly specified to have [[Prototype]] of null.

Or did you mean something else?
Comment 5 John-David Dalton 2010-11-11 09:31:53 PST
I know there are also issues with expando's and cloneNode() in IE (IE copies non-object value expandos to the clone, and also issues with some Java Applets barfing when devs attempt to set expando's on them.
Comment 6 Lucas Forschler 2019-02-06 09:03:36 PST
Mass moving XML DOM bugs to the "DOM" Component.
Comment 7 Anne van Kesteren 2023-08-26 01:08:50 PDT
This feature is no longer standardized. The alternative is using WeakMap.