[whatwg] Value attribute (was: Re: [WA1] GUI Selections)

 > Okay. I just skimmed the spec, so maybe it does. Doesn't really
 > matter, though, because the .value property is still not the same as
 > the |value| attribute or the contents of a <textarea> element,

Regarding the "value" property in the DOM, I think it's a bit confusing, 
but this is how I understand it:

The "value" property in the DOM reflects the current state of the input 
control in the UA. If the user edits the content of the input field, the 
DOM "value" property is updated.
However the contents of the "value" attribute in the original HTML 
source  is represented by the "defaultValue" DOM attribute. (This is 
also the initial value of the "value" attribute in the DOM). This is 
important for the reset button, but especially important if you are 
*editing* a HTML document rather than browsing it. When the document is 
serialized back to HTML by the editor, the "value" attribute in the HTML 
is generated from the "defaultValue" DOM attribute. OTOH the "value" DOM 
property is not serialized (and typically you won't change that in an 
editor anyway).

Think of it as currentValue and defaultValue. Both exists in the DOM, 
but only defaultValue is represented in the HTML source. The confusing 
part is that in HTML defaultValue is called "value", while in the DOM it 
is currentValue that is called "value".

Anyway, editing the value of an input field does change the DOM "value" 
attribute, but does not change the "value" content attribute in the 
underlying HTML.

regards
Olav Junker Kj?r

Received on Thursday, 24 February 2005 02:04:23 UTC