Henri Sivonen wrote:
I try to associate DOM nodes with other objects. Assigning custom
properties to DOM nodes works in Firefox and Safari. It also works with
HTML nodes in IE6. However, it appears not to work with XML nodes that
are part of trees returned by XMLHttpRequest.
Are you sure about XMLHttpRequest? That is implemented in Mozilla and in
Mozilla there is a common DOM for XML and HTML nodes so I am pretty sure
that at least Mozilla allows you to use an XML DOM node the same way as
an HTML DOM node where you could do
node.someProperty = expression;
The same for Opera 8.00 beta.
I am not sure about Safari and can't test while I am on Windows.
But I rather think IE is the one making problems as there XML DOM is not
integrated in the browser but provided by MSXML as ActiveX objects which
usually do not allow script to add custom properties.
How can I work around this
limitation? For XML nodes, I need to be able to associate at most one
object with each node.
You would need to do it the other way round, create your own wrapper
constructor function e.g.
function MyXmlNode (domNode) {
this.domNode = domNode;
}
then create wrapper objects where needed
var aNode = new MyXmlNode(someDomNode);
and add properties where needed:
aNode.someProperty = expression;
--
Martin Honnen
http://JavaScript.FAQTs.com/