Re: HTMLOptionElement.selected vs defaultSelected

John Whelan posted on this topic about two weeks ago, and I have exactly  the
same query. As John seemed to nail the argument exactly, I'll just quote his
post:

John Whelan wrote:
> 
> I'm confused about the selected and defaultSelected attributes of the
> HMTLOptionElement interface in the the DOM Level One spec
> http://www.w3.org/TR/REC-DOM-Level-1/level-one-html.html#ID-70901257
> 
> According to the spec, defaultSelected is read-write and "Stores the
> initial value of the selected attribute", while selected is read-only
> and "Means that this option is initially selected.  See the selected
> attribute definition in HTML 4.0."
> 
> Now, with the exception of the definition given for defaultSelected,
> this seems to be reversed from the JavaScript definitions of these two
> attributes.  In JavaScript, defaultSelected is read-only, and is set
> by the value of the OPTION element's SELECTED attribute, while
> selected is read-write, and determines whether the option is selected
> (either by the user or by a scripting event).
> 
> The DOM spec appears to be in error (or at least nonsensical) here:
> if selected is a read-only attribute declaring whether the Option is
> initially selected, then what's the point of having a defaultSelected
> attribute which stores its initial value (and is read-write, to boot)?
> 
>                                         John T. Whelan
>                                         whelan@iname.com
>                                         http://www.slack.net/~whelan/

I agree that the DOM spec seems counter intuitive, and at odds with
JavaScript. Can we assume it's just a typo?

djw

Received on Friday, 27 November 1998 16:18:12 UTC