[whatwg] Arbitrary HTML in option-elements

Matthew Raymond wrote:
 > I doubt that you'd see popular user agents implement support for
 > undefined behavior unless there's a specific use case that becomes 
common.

Sure, but I think the use case for more than plain text in options is 
pretty strong. Look at the toolbars in e.g. Microsoft Word, there is 
lots of dropdowns, and almost all of them have icons beside the textual 
content.

And the spec mentions it: (section 2.18)

 > Two possibilities are sensible: rendering the content normally, just
 > as it would have been outside the form control; and rendering the
 > initial value only, with the rest of the content not displayed (unless
 > forced to appear through some CSS).

This implies that rendering e.g. img-tags in an option-element is an 
optional feature. But in Appendix A it's clearly illegal. I think this 
is inconsistent.

Generally, I think its a very good thing that the spec tries to define 
how to handle invalid HTML. Undefined and optional behavior in 
interpreting HTML is bad thing IMHO.

Maybe the rules for parsing invalid HTML (in HTML5) could be 
generalized, something like:

- Unsupported element, or elements in a context where they are not 
allowed because of the DTD, should be ignored. However, if the ignored 
element has textual content, and the context allows pcdata, the content 
should be rendered.
- Attributes with a value that is malformed or illegal according to the 
spec should be ignored. Unknown or unsupported attributes should be ignored.

I think this is more or less consistent with current user agent 
behavior, however it greatly reduces the amount of unspecified behavior.

Of course, following these rules, anything but text content should be 
ignored in OPTION-elements.

Olav Junker Kj?r

Received on Tuesday, 30 November 2004 13:38:44 UTC