473,770 Members | 7,142 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.customprop erty = value

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


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.someProper ty = 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(someD omNode);
and add properties where needed:
aNode.somePrope rty = expression;
--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 23 '05 #2
In article <42************ ***********@new sread2.arcor-online.net>,
Martin Honnen <ma*******@yaho o.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.someProper ty = 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(someD omNode);
and add properties where needed:
aNode.somePrope rty = 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
4690
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 template. I now wish take a sizeable amount of data and create an xml file based on these classes. My intent is to use xmldocument to build up the xml and then stream it to a file. My
6
2227
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 class would have CurrentUser property that would hold customer class in session and that was fine for all my situations. Now ASP.NET 2.0 came and we have Profile property for pages that could be extended with configuration to have custom...
6
3802
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" type="ComIT.Applications.Common.ConfigurationSections.MyHandler" allowLocation="true" allowDefinition="Everywhere" /> </configSections>
0
2597
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. For example: Public Class CustomTreeNode Inherits TreeNode
7
4748
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 project. The same class lib is included in the ASP.NET Web Application that calls the web-method I can successfully call the web-method with
2
3818
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 I have followed the sample code provided on the MSDN website for writing a custom HierarchicalDataSourceControl, HierarchicalDataSourceView, IHierarchicalEnumerable, and IHierarchyData implementations (their FileSystem example).
2
1929
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 the nodes are being correctly populated. However, when used with a TreeView control, only the first node displays. Any suggestions on why this might be the case? Thanks.
0
2137
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 to ASP.NET 2.0. The conversion is going well because some of the features, like Master Pages and Site Maps, of ASP.NET 2.0 allow us to migrate away from a "top frame" style of navigation to a standard dynamic cascading top menu with minimal...
0
2487
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 render it within my control it crashes and burns. I've even tried placing it within another control (a PlaceHolder) and tried to render the PlaceHolder to no avail. Any ideas on how to fix this problem? Here's my code:
0
9592
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9425
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10230
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10058
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10004
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9870
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8886
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6678
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5450
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.