Closed Bug 62043 Opened 24 years ago Closed 23 years ago

HTMLInputElement.default{Checked,Value} problem

Categories

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

defect

Tracking

()

RESOLVED FIXED
mozilla0.9.7

People

(Reporter: jst, Assigned: jst)

References

Details

(Keywords: dom0, Whiteboard: [HAVE FIX])

The semantics of the properties .defaultValue and .defaultChecked in mozilla/ns6
is currently by the DOM Level 2 working draft but unfortunately the wd is
incorrect, the spec was supposed to define the behavior of NS 3.0 and IE 3.0 yet
those browsers don't behave like the spec says. The description of the
properties is as folows:

  defaultChecked of type boolean
    When type has the value "Radio" or "Checkbox", this represents the HTML
    checked attribute of the element. The value of this attribute does not
    change if the state of the corresponding form control, in an interactive
    user agent, changes. Changes to this attribute, however, resets the state
    of the form control. See the checked attribute definition in HTML 4.0.

  defaultValue of type DOMString
    When the type attribute of the element has the value "Text", "File" or
    "Password", this represents the HTML value attribute of the element. The
    value of this attribute does not change if the contents of the
    corresponding form control, in an interactive user agent, changes.
    Changing this attribute, however, resets the contents of the form control.
    See the value attribute definition in HTML 4.0.

The problem is the sentence "Changes to this attribute, however, resets the
state of the form control." in the description of both properties.

if that sentence was removed from the DOM spec the description would match the
implementations. The Mozilla implementation should be changed to match the old
behavior.

Interestingly enough the Level 1 DOM HTML spec contains these descriptions:

  defaultValue
    Stores the initial control value (i.e., the initial value of value).

  defaultChecked
    When type has the value "Radio" or "Checkbox", stores the initial value of
    the checked attribute.

which is probably more correct than the current Level 2 DOM HTML working draft
(and the second edition of the Level 1 DOM HTML).

Vidur, do you know why this was changed in the DOM spec?
This patch fixes this problem:

Index: layout/html/content/src/nsHTMLInputElement.cpp
===================================================================
RCS file: /cvsroot/mozilla/layout/html/content/src/nsHTMLInputElement.cpp,v
retrieving revision 1.149
diff -u -r1.149 nsHTMLInputElement.cpp
--- nsHTMLInputElement.cpp      2000/12/23 10:56:15     1.149
+++ nsHTMLInputElement.cpp      2001/01/01 03:11:24
@@ -356,11 +356,6 @@
     rv = UnsetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::checked, PR_TRUE);
   }

-  if (NS_SUCCEEDED(rv)) {
-    //When setting DefaultChecked, we must also reset Checked (DOM Errata)
-    SetChecked(aDefaultChecked);
-  }
-
   return rv;
 }

I'm working on getting this fixed in the DOM spec too.
Status: NEW → ASSIGNED
Whiteboard: [HAVE FIX]
Target Milestone: --- → mozilla0.9
*** Bug 12348 has been marked as a duplicate of this bug. ***
Keywords: dom0
Pushing to mozilla0.9.1
Target Milestone: mozilla0.9 → mozilla0.9.1
moving to TM of 0.9.2 per PDT triage (you can check it into 0.9.1 until Friday,
18/May/01 or into 0.9.2 after the tree opens)
Target Milestone: mozilla0.9.1 → mozilla0.9.2
Moving to mozilla0.9.3
Target Milestone: mozilla0.9.2 → mozilla0.9.3
Target Milestone: mozilla0.9.3 → mozilla0.9.4
Pushing to mozilla0.9.5
Target Milestone: mozilla0.9.4 → mozilla0.9.5
Target Milestone: mozilla0.9.5 → mozilla0.9.6
Pushing to mozilla0.9.7
Target Milestone: mozilla0.9.6 → mozilla0.9.7
John Keiser fixed this one with his form rewrite...
Status: ASSIGNED → RESOLVED
Closed: 23 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.