Closed Bug 106185 Opened 24 years ago Closed 1 year ago

DOM Element has non-null nodeValue attribute

Categories

(Core Graveyard :: Java APIs for DOM, defect)

x86
Windows 2000
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED INCOMPLETE

People

(Reporter: mpepstei, Assigned: ashuk)

Details

Not sure whether this problem is in the DOM implementation or the Java wrapper for it, but it clearly states in the DOM Level 2 Core Spec. that calling getNodeValue() on an Element should return null. I've been working with form elements and it seems that getNodeValue() returns the current value for INPUT elements. I don't particularly have a problem with this, but technically it doesn't comply with the DOM, and, more importantly, it is not clearly stated in the API or sample code (as far as I can tell), that this is the way to get the current value of a text field in a form. After struggling with textfield.getAttribute("value"), I learned from a newsgroup that this will always supply the default value. This article (http://groups.google.com/groups? hl=en&threadm=8r91o3%24eq91%40secnews.netscape.com&rnum=1&prev=/groups%3Fq% 3Dmozilla%2Bdom%2Bform%2Bvalue%26hl%3Den%26group%3Dnetscape.public.mozilla.java% 26rnum%3D1%26selm%3D8r91o3%2524eq91%2540secnews.netscape.com) also implies that the proper way to get the current value is to cast the element to HTMLInputElement and call that interface's getValue() method. The Java DOM for Mozilla doesn't seem to have this interface, and after looking through the code for org.mozilla.webclient.test.DOMAccessPanel it became clear that calling getNodeValue() was the way to get the value. I understand time and resource constraints may prevent full compatibility with DOM Level 2, but shouldn't something like this be clearly documented somewhere? A related issue concerns TEXTAREA elements. The value of a TEXTAREA should be contained in a TEXT node inside of it, but using the DOMViewer that is part of the sample application that comes with the Webclient, it is possible to set the text by typing it into the value field or by adding a TEXT node as a child of the TEXTAREA (as it should be). What's troubling is that it is possible to add different values using both of these methods. Did I miss an explanation of these inconsistencies somewhere or are they not documented?
we _are_ talking about Java, not JavaScript, right?
That is correct. I am referring to Java classes in the packages under org.mozilla Most of the classes I use directly are in org.mozilla.webclient, but I suspect the DOM implementation is backed by classes in org.mozilla.dom. The problem may not even lie in these classes--it could be in the native Mozilla DOM implementation.
OK. The proper way to get the current value of a form element is: element.getValue() This is not the same as element.getAttribute("value"), as you pointed out. Doesn't really affect this bug, but thought I'd let you know. :)
Status: UNCONFIRMED → NEW
Ever confirmed: true
Product: Core → Core Graveyard
Status: NEW → RESOLVED
Closed: 1 year ago
Resolution: --- → INCOMPLETE
You need to log in before you can comment on or make changes to this bug.