[whatwg] Re: Suggestions: <select datalist> and the functionality of the |for| attribute.

Ian Hickson wrote:
> I feel I missed something somewhere. What is wrong with <datalist>?

    It mixes the legacy markup and <option> elements, and in fact could 
even theoretically allow invalid legacy markup on WF2 clients, since on 
such clients it ignores everything but <option> elements. So I could do 
the following...

<datalist id="myList">
   <html>
     <body></body>
     <body></body>
     <head>
     <select>
       <option>Item 1</option>
     </select>
     <select>
       <option>Item 2</option>
     </select>
     <select>
     </select>
     <option>Item 3</option>
     <option>Item 4</option>
     <option>Item 5</option>
     </head>
   </html>
</datalist>

...And a WF2-compliant UA would treat the above the same as this:

<datalist id="myList">
   <option>Item 1</option>
   <option>Item 2</option>
   <option>Item 3</option>
   <option>Item 4</option>
   <option>Item 5</option>
</datalist>

    In other words, there is no separation of legacy code and list 
options. The same might be true with <select>, of course, but there it's 
not rendered because the markup isn't supposed to be there in the first 
place, not because it's defined as a way of handling legacy code.

> What about if you want to not have the <datalist> appear in legacy UAs at
> all, for example if you are just doing:
> 
>    <input type="range" list="tick-marks" name="v1" min="1">
>    <input type="range" list="tick-marks" name="v2" min="1">
>    <input type="range" list="tick-marks" name="v3" min="1">
>    <datalist id="tick-marks">
>      <option value="1">
>      <option value="5">
>      <option value="10">
>      <option value="50">
>      <option value="100">
>    </datalist>
 >
> Here you don't want the list to appear in legacy UAs, in legacy UAs you
> just want three text boxes.

    This case was not brought up previously. I agree, this would be a 
primary reason for not using <select> for the purpose of storing list 
options, although one should still be able to use |list| to get a list 
of options from a <select> element.

    Despite my distaste for how <datalist> handles legacy code, I must 
concede that it is the best solution presented on the mailing list, and 
I approve of its inclusion in the latest draft of Web Forms 2.0.

Received on Wednesday, 7 July 2004 10:28:21 UTC