[whatwg] Improve select required

Hi,

I am glad that select required has been accepted and introduced in the
specifications. However, I have the feeling we could try to improve that
feature.

Currently, if multiple is set or size>1, having no option selected make
the element suffering from constraint validation. If multiple is not set
or size=1, the element suffer from constraint validation if the
"placeholder label option" is selected. This is not really
straightforward and the "placeholder label option" thing even less.

We could keep the rule "if an option is selected then the element
requirement is fulfilled" even for non-multiple select with size=1
select. However, we know that authors put options they don't want to be
selected. It seems that there is two reasons:
1. want to show a placeholder
2. they don't use <optgroup> so they use an option with no value to show
a group name or a separator

I see a few ways that may fix that:
1. Select elements will suffer from being missing if there are no
options selected or all selected options have no value (empty string).
2. Introduce a placeholder boolean attribute for <option> and select
elements will suffer from being missing if there are no options selected
or selected options all have the placeholder attribute set.
3. Introduce a placeholder attribute for <select> which will show the
text as a placeholder. So, there would be no pre-selected option. Thus,
the select element would suffer from being missing if no option is selected.

Solutions 1 and 2 are backward compatible but the last solution isn't
(ie. the placeholder text wouldn't be shown). However, a workaround can
be found using javascript: if an option marked as disabled and selected
is inserted as the first child of a select, it will be shown but not
selectable (tested with Chromium 7.0.503, Firefox 4 b6pre and Opera
10.70). Actually, it looks like this behavior is forbidden by the
specifications...

Solution 3, seems to be the nicest and is consistent with the other part
of the specifications (placeholder would be used in <input> and <select>).

We might implement one of these propositions in Gecko 2.0 beta6 so,
feedbacks would be appreciated.

Thanks,
--
Mounir

Received on Sunday, 12 September 2010 22:57:38 UTC