[whatwg] Web Forms: SELECT, OPTION, and defaultSelected

Section 2.3

I didn't get any responses on this. It doesn't have any cool like ajax
offline; it is a more fundamental (basic) requirement.

There is a shortcoming in the specification.

================================================================
2.3. Extensions to the select element

Previous versions of Web Forms were inconsistent about whether the
first option element of a single-select select element with no
otherwise-selected items should be automatically selected. According
to [RFC1866], it should be, and according to [HTML4] it was undefined.
User agents implementing this specification must select the initial
option element of a single-select select element with no
otherwise-selected items.
================================================================

I would like the defaultSelected for this behavior to be true.

Currently there is a problem in at least Firefox, and I can't remember
about IE. If no OPTION has selected attribute, then Firefox will
select the first option in the list. If the first option is selected,
it's selected attribute will be true and the defaultSelected will be
false. This is because defaultSelected is required to return the value
of the HTML selected attribute.

The negative result this has is that it causes the form to appear dirty.

Form dirty notification is quite useful in modern Ajax applications.
In fact, it is useful to broadcast a custom "dirty" event from a FORM
wrapper class (ES). That way, subscribers can listen for the event and
enable a submit button, for example.

I have implemented this particular example use-case and run into the
very problem. The solution was to require the clients (other
developers using the FORM wrapper code) to explicitly use the selected
attribute.

My proposal is to change the text as follows:
================================================================
2.3. Extensions to the select element

Previous versions of Web Forms were inconsistent about whether the
first option element of a single-select select element with no
otherwise-selected items should be automatically selected. According
to [RFC1866], it should be, and according to [HTML4] it was undefined.
User agents implementing this specification must select the initial
option element of a single-select select element with no
otherwise-selected items ***and set its defaultSelected value to
true.***
================================================================

Garrett


http://lists.whatwg.org/htdig.cgi/whatwg-whatwg.org/2007-August/012445.html


-- 
Programming is a collaborative art.

Received on Thursday, 13 September 2007 17:16:42 UTC