W3C home > Mailing lists > Public > whatwg@whatwg.org > February 2005

(unknown charset) [whatwg] Value attribute

From: (unknown charset) Olav Junker Kjær <olav@olav.dk>
Date: Thu, 24 Feb 2005 15:18:16 +0100
Message-ID: <421DE228.60502@olav.dk>
Matthew Raymond wrote:
>    In general, if you set a DOM property, it won't set the actual 
> attribute in markup. In order to change the markup, I think you have to 
> use the setAttribute method. However, I believe that the setAttribute 
> method does change the DOM property.

Did a quick test: In Mozilla, IE and Opera setting an ordinary attribute 
through a DOM property seems to be equivalent to using setAttribute. The 
"value" property is handled differently though. In IE and Opera 
getAttribute("value") returns the same as the "value" DOM property, 
while in Mozilla it returns the same as the defaultValue property (which 
is the correct behavior, I think). However, using innerHTML in Opera 
seem to serialize the element correctly by using the defaultValue 
property as at content of the value HTML, as does Mozilla.

Anyway, your original statment that DOM Range couldn't work on the 
current value in an input field seems to be correct. The DOM Range may 
work on an Attr node but not any DOM attribute. The current value is in 
the DOM in the form of an property, but not in the form of a DOM Attr node.

regards
Olav
Received on Thursday, 24 February 2005 06:18:16 UTC

This archive was generated by hypermail 2.3.1 : Monday, 13 April 2015 23:08:21 UTC