W3C home > Mailing lists > Public > www-dom@w3.org > January to March 2002

Re: Feature suggestion: Hook property on Node

From: Philippe Le Hegaret <plh@w3.org>
Date: Wed, 30 Jan 2002 10:15:01 -0500
Message-ID: <3C580DF5.8E6DE496@w3.org>
To: Ronald Bourret <rpbourret@rpbourret.com>
Cc: www-dom@w3.org
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 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Friday, 22 June 2012 06:13:55 GMT