473,396 Members | 1,804 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Custom properties on DOM nodes

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. How can I work around this
limitation? For XML nodes, I need to be able to associate at most one
object with each node.

The syntax I am using is
node.customproperty = value

--
Henri Sivonen
hs******@iki.fi
http://hsivonen.iki.fi/
Jul 23 '05 #1
2 2081


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/
Jul 23 '05 #2
In article <42***********************@newsread2.arcor-online.net>,
Martin Honnen <ma*******@yahoo.de> wrote:
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;


I formulated my post badly. My point was that it does work on the XML
side in Mozilla and Safari but not in IE.

At least I think it works in Safari. Safari is broken in many ways and I
have not yet fully ported to Safari, but so far this particular feature
appears to work.
The same for Opera 8.00 beta.
Cool. I haven't even tested in Opera 8, yet, because the OS X beta
crashes on launch on my system.
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.


Right.
> 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;


Thanks. That will get messy, because I will then have to support walking
the tree using the wrappers. :-(

--
Henri Sivonen
hs******@iki.fi
http://hsivonen.iki.fi/
Jul 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Ian Williamson | last post by:
Greetings, I have seen this question posted a few times, but the answers have not helped me. I have used the program xsd.exe to generate several c# classes from a client provided xsd...
6
by: Shimon Sim | last post by:
Hi I am working on application that need to hold custom user information - Last and first name, email, some other domain related information. I used to create Base class for all my pages. The base...
6
by: Tabi | last post by:
Hi, I want to create a custom section in my web.config that can hold my custom values. I created a section in web.config as written below. <configSections> <section name="myCustomSection"...
0
by: Bishop | last post by:
I've figured out how to create a custom TreeNode with custom properties and I can view those properties at runtime, but I'm not sure how to change them after I've added the custom node to the tree....
7
by: John Grandy | last post by:
My ASP.NET Web Service project has a Web Method that returns an array filled with instances of a custom class. The custom class is defined in a Class Library that is included in the web-service...
2
by: Eamon Millman | last post by:
Greetings, I'm fairly new to the new ASP.NET 2.0 controls and I'm trying to get the TreeView control to display some non-xml/sitemap data I want to have in a tree format. To accomplish this...
2
by: dhurwitz | last post by:
Hi, I have written a custom SiteMapProvider to retrieve site map data from a SQL Server database table. It works fine when used as the data source for a Menu control, so I am confident that all...
0
by: Alex Brown | last post by:
Is it a problem to attach Non-static site map providers under one that inherits from StaticSiteMapProvider ? We are implementing a custom site map provider for a website that is being converted...
0
by: apenly | last post by:
Hi all- I'm trying to Render a TreeView in a custom control, but I'm receiving a NullReferenceException at runtime. If I put the TreeView on the page it works fine, but as soon as I try to...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.