Re: Feature suggestion: Hook property on Node

Ronald Bourret wrote:
> 
> It would be nice if the Node interface had a "hook" property -- that is,
> a read/write property in which the user could store any value they like.

Check the DOM Level 3 Core draft:
http://www.w3.org/TR/2002/WD-DOM-Level-3-Core-20020114/core.html#Node3-setUserData

The intent is to address the "hook" property as well as memory management
associated with it and multi-threading environment.

Feedback is welcome.

> (I don't know what the IDL type is, but this would be equivalent to
> Object in Java or void * in C/C++.)

The type Object exists in IDL. 

> As an example of why this is useful, consider the problem of
> constructing a DOM tree based on external order information. That is,
> the DOM construction code receives DOM nodes along with the information,
> "This is the third child," "This is the fourteenth child," etc. To
> perform this task, the code needs to know the order value associated
> with each node in the tree.
> 
> With a hook property, the application could store order values with each
> node and either build the tree in sorted order or sort after the tree is
> complete. Without a hook property, the application must encapsulate each
> node and add the order property -- more work than seems necessary.
> 

> Another use (inspired by recent discussions on xml-dev) would be storing
> the current namespace scoping information. I am certain that many other
> uses/abuses could be found as well.

As a side comment, the DOM Level 3 XPath gives you this information:
http://www.w3.org/TR/2001/WD-DOM-Level-3-XPath-20011031/xpath.html#XPathNamespace

We didn't find any interest or enough use cases to add this Node into
the DOM Level 3 Core module. XPath was our only main one.

Philippe

Received on Wednesday, 30 January 2002 10:15:08 UTC