[whatwg] [Web Forms 2.0] 2.3. Extensions to the select element - comment & proposal

Garrett Smith dhtmlkitchen at gmail.com
Mon Aug 27 13:55:17 PDT 2007


================================================================
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://dhtmlkitchen.com/



More information about the whatwg mailing list