[whatwg] Option label, textContent and value

In 4.10.12 on the Option element, the spec states:

"
The label attribute provides a label for element. The label of an option 
element is the value of the label attribute, if there is one, or the 
textContent of the element, if there isn't.

The value attribute provides a value for element. The value of an option 
element is the value of the value attribute, if there is one, or the 
textContent of the element, if there isn't.
"

It looks like this needs clarification for the case both label attribute 
and text content are present, as UAs do not implement this consistently:

<select>
   <option label="Label1">TextContent1</option>
   <option label="Label2">TextContent2</option>
</select>

- IE 8, Opera 11 and Chrome 9 display "Label1" and "Label2"
- Firefox 3.6 displays "TextContent1" and "TextContent2"

Firefox's behavour seems to be contradictory to the spec, which gives 
the label attribute precedence.

Furthermore, as I understand the above definitions, the spec does allow 
to specify label and value in one step in a select element:

<select>
   <option>This is value and label
</select>

But not in a datalist, as the label is taken from the textContent rather 
than from the value of the option element:

<datalist>
   <option value="No label here">
   <option label="No value here">
</datalist>

I'd propose to slightly change the specification to treat the value the 
same, regardless whether it is given in the value attribute or in the 
text content, and to get the label, where the label attribute is 
missing, from the value rather than from the text content:

"
The value attribute provides a value for element. The value of an option 
element is the value of the value attribute, if there is one, or the 
textContent of the element, if there isn't.

The label attribute provides a label for element. The label of an option 
element is the value of the label attribute, if there is one, or the 
value of the element, if there isn't.
"

Received on Tuesday, 8 March 2011 05:22:29 UTC