Bug 7255 - label attribute in option elements is ignored
Summary: label attribute in option elements is ignored
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Forms (show other bugs)
Version: 412
Hardware: Mac OS X 10.4
: P2 Normal
Assignee: John Sullivan
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-02-14 12:14 PST by John Sullivan
Modified: 2006-02-14 14:38 PST (History)
0 users

See Also:


Attachments
test cases that include empty label (282 bytes, text/html)
2006-02-14 12:28 PST, John Sullivan
no flags Details
patch to support label attribute for OPTION elements (953 bytes, patch)
2006-02-14 12:31 PST, John Sullivan
adele: review+
Details | Formatted Diff | Diff
layout tests for patch (1.09 KB, text/plain)
2006-02-14 13:26 PST, John Sullivan
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description John Sullivan 2006-02-14 12:14:14 PST
The OPTION element has a "label" attribute which, when present, is supposed to be used in the user interface rather than the text contents of the element. This is described on <http://www.w3.org/TR/REC-html40/interact/forms.html>:

This attribute allows authors to specify a shorter label for an option than the content of the OPTION element. When specified, user agents should use the value of this attribute rather than the content of the OPTION element as the option label.

WebKit ignores this attribute, though a getter and setter are supplied in the Objective-C DOM API at least.

IE supports this attribute, though Firefox ignores it.

Here's an example. This should show a pop-up menu with menu items titled "1" and "2", but instead it shows a pop-up menu with long menu item titles:

<select>
<option value="1" label="1">the label for this element is "1"</option>
<option value="2" label="2">the label for this element is "2"</option>
</select>
Comment 1 John Sullivan 2006-02-14 12:28:37 PST
Created attachment 6487 [details]
test cases that include empty label
Comment 2 John Sullivan 2006-02-14 12:31:11 PST
Created attachment 6488 [details]
patch to support label attribute for OPTION elements
Comment 3 John Sullivan 2006-02-14 12:37:50 PST
Comment on attachment 6488 [details]
patch to support label attribute for OPTION elements

Oops, I didn't mean to mark it review-+. Also, I haven't attached the layout tests yet, so I'll set this to review- until I have the tests ready.
Comment 4 John Sullivan 2006-02-14 13:26:54 PST
Created attachment 6489 [details]
layout tests for patch
Comment 5 John Sullivan 2006-02-14 13:27:29 PST
Comment on attachment 6488 [details]
patch to support label attribute for OPTION elements

Now that I've attached the new layout tests, this is ready for review.
Comment 6 Dave Hyatt 2006-02-14 14:07:08 PST
HTML also will let you write:

<option label>Foo</option>

Should make sure we match WinIE in that situation too.
Comment 7 Dave Hyatt 2006-02-14 14:07:33 PST
Also, what about list boxes?  Need to see if label is used for <select size="10"> for example.
Comment 8 Dave Hyatt 2006-02-14 14:07:47 PST
Also need to test optgroups.
Comment 9 John Sullivan 2006-02-14 14:18:19 PST
In response to comment 6: the behavior for this case is the same on MacIE as in WebKit; I'll add a layout test.

In response to comment 7:  list boxes don't use the label but should; I'll write a bug

In response to comment 8: optgroups already deal with the label (used as hierarchical menu item title)
Comment 10 John Sullivan 2006-02-14 14:38:38 PST
I was wrong about list boxes in my previous comment; they do work correctly now with label attributes. (I was using the wrong Safari when I tested that case.) I'm adding another layout test for this.