Closed Bug 76039 Opened 25 years ago Closed 23 years ago

XML doc's getElementById does not match element in XUL namespace

Categories

(Core :: DOM: Core & HTML, defect, P5)

x86
Windows 2000
defect

Tracking

()

VERIFIED WORKSFORME
Future

People

(Reporter: pwilson, Assigned: hjtoi-bugzilla)

Details

(Keywords: testcase)

Attachments

(1 file)

getElementById always returns null on a DOM returned from nsDOMParser. getElementsByTabName and XMLSerializer both work fine.
Have attached an amended utility.js file to show this bug. Otherwise, use same files attached to bug # 75844
Reassigning to heikki.
Assignee: jst → heikki
Marking NEW.
Status: UNCONFIRMED → NEW
Ever confirmed: true
Keywords: testcase
I guess this one needs a simplified testcase. But I am wondering if there is in fact some misunderstanding in here. Are you sure you are loading an XML document that has an internal subset that defines the attribute as type ID? If you do not do that, there is no way getElementById() will work. So, the file you load, does it look something like: <!DOCTYPE doc [ <!ATTLIST p id ID #IMPLIED> ]> <doc> <p>Foobar</p> <p id="myid1">You can get this with getElementById("myid1")</p> </doc> ? Using the XHTML namespace will also work, i.e. if you have XHTML element with attribute named "id", getElementById() will locate it. Other namespaces are not supported in this way.
The xml being loaded is the test.xul file which runs the test. Btw the getElementById's in test.js should have "button1" as the parameter and not "label1". See also Bug # 78622
I am changing the summary as I know believe the problem is that we are not finding the XUL element with an id attribute. The XUL file does not explicitly state the type of the ID attribute, and XML document's getElementById() only matches attributes of type ID and XHTML id. I am not sure if we even want to add special support for XUL namespace in normal XML document. The probable workaround would be to explicitly state in the XUL file which attributes are of type ID. Moving to 1.0 for fix or re-evaluation.
Summary: getElementById returns null when document loaded by nsIDOMParser → XML doc's getElementById does not match element in XUL namespace
Target Milestone: --- → mozilla1.0
Updating QA contact to Shivakiran Tummala.
QA Contact: desale → stummala
Target Milestone: mozilla1.0 → mozilla0.9.9
Target Milestone: mozilla0.9.9 → Future
Priority: -- → P5
From looking at the code, this is worksforme. I tried a doc=document.implementation.createDocument('','',null); // XMLDocument doc.load("foo.xul"); doc.getElementById('bar'); which gave the same results as loading foo.xul in DOM inspector. Same for aDOMParser.parseFromString('<?xml version="1.0"?>\n<window id="WindowWithViews" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"><vbox id="shell"/></window>','text/xml') [object XMLDocument] js> dd.getElementById("junk") js> dd.getElementById("shell") [object XULElement] code is http://lxr.mozilla.org/seamonkey/source/content/xul/content/src/nsXULElement.cpp#3574 Please reopen with a testcase if I suck.
Status: NEW → RESOLVED
Closed: 23 years ago
Resolution: --- → WORKSFORME
Dunno when this changed, but I can verify this now works.
Status: RESOLVED → VERIFIED
Component: DOM: Core → DOM: Core & HTML
QA Contact: stummala → general
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: