This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 18645 - [Shadow]: HTMLSelectElement should have an insertion point
Summary: [Shadow]: HTMLSelectElement should have an insertion point
Status: RESOLVED LATER
Alias: None
Product: WebAppsWG
Classification: Unclassified
Component: HISTORICAL - Component Model (show other bugs)
Version: unspecified
Hardware: PC All
: P2 normal
Target Milestone: ---
Assignee: Dimitri Glazkov
QA Contact: public-webapps-bugzilla
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 18428
  Show dependency treegraph
 
Reported: 2012-08-21 18:43 UTC by Dimitri Glazkov
Modified: 2012-10-31 22:20 UTC (History)
3 users (show)

See Also:


Attachments

Description Dimitri Glazkov 2012-08-21 18:43:31 UTC
The way it behaves in real world, the HTMLSelectElement should have one insertion point that selects "option" elements.
Comment 1 Shinya Kawanaka 2012-08-22 04:52:14 UTC
Actually a <select> element will get not only the direct children <option> but also get non direct children.

For example, 

​<select>
<option>foo</option>
<p><option>bar</option></p>
</select>​​​​​​​​​​​​​​​​​​​​​​​​​​

both 'foo' and 'bar' will be used in this case.

It seems this description is not accurate enough. I'm not sure we have enough descriptive power to explain this behavior using Shadow DOM.
Comment 2 Dimitri Glazkov 2012-08-22 16:59:32 UTC
(In reply to comment #1)
> Actually a <select> element will get not only the direct children <option> but
> also get non direct children.
> 
> For example, 
> 
> ​<select>
> <option>foo</option>
> <p><option>bar</option></p>
> </select>​​​​​​​​​​​​​​​​​​​​​​​​​​
> 
> both 'foo' and 'bar' will be used in this case.

Right, but in this case, the HTML parser is playing tricks on you. Look at the resulting DOM tree: you'll see that <p> is silently dropped. However, if still you try to create this structure imperatively, you'll see that only <options> that are direct children are shown:

http://software.hixie.ch/utilities/js/live-dom-viewer/?%3C!DOCTYPE%20html%3E%0A%3Cselect%3E%0A%3Coption%3Efoo%3C%2Foption%3E%0A%3Cp%3E%3Coption%3Ebar%3C%2Foption%3E%3C%2Fp%3E%0A%3C%2Fselect%3E%E2%80%8B%E2%80%8B%E2%80%8B%E2%80%8B%E2%80%8B%E2%80%8B%E2%80%8B%E2%80%8B%E2%80%8B%E2%80%8B%E2%80%8B%E2%80%8B%E2%80%8B%E2%80%8B%E2%80%8B%E2%80%8B%E2%80%8B%E2%80%8B%E2%80%8B%E2%80%8B%E2%80%8B%0A%3Cscript%3E%0A%0Avar%20option%20%3D%20document.createElement('option')%3B%0Aoption.textContent%20%3D%20'baz'%3B%0Avar%20p%20%3D%20document.createElement('p')%3B%0Ap.appendChild(option)%3B%0Adocument.querySelector('select').appendChild(p)%3B%0A%0A%3C%2Fscript%3E
Comment 3 Dominic Cooney 2012-08-23 02:33:07 UTC
I think <select> should not have an insertion point. The spec should be amended to treat it along with input, etc.

The spec should ensure that:

<select>
    {SR}
        <option>Asparagus
        <content>
    <option>Banana
    <option>Pear

should render "Asparagus", and not a select box (and definitely not a select box with Asparagus, Banana, Pear.) The reason being that the selectedIndex of Asparagus does not make sense. Asparagus is not in the data model of the select element.
Comment 4 Dimitri Glazkov 2012-08-23 02:59:54 UTC
(In reply to comment #3)
> I think <select> should not have an insertion point. The spec should be amended
> to treat it along with input, etc.
> 
> The spec should ensure that:
> 
> <select>
>     {SR}
>         <option>Asparagus
>         <content>
>     <option>Banana
>     <option>Pear
> 
> should render "Asparagus", and not a select box (and definitely not a select
> box with Asparagus, Banana, Pear.) The reason being that the selectedIndex of
> Asparagus does not make sense. Asparagus is not in the data model of the select
> element.

It can't render "Asparagus", since options are not rendered.

Can you explain the problem you're seeing with <select> having an insertion point?
Comment 5 Olli Pettay 2012-08-23 14:18:03 UTC
We should not add any special cases to Shadom DOM at this point. 
Once the spec is otherwise stable, there could a yet another
spec defining additions to HTML elements (if really needed).
Comment 6 Dominic Cooney 2012-08-23 16:07:47 UTC
(In reply to comment #4)
> It can't render "Asparagus", since options are not rendered.

That is OK.
 
> Can you explain the problem you're seeing with <select> having an insertion
> point?

On reflection I think my beef is not with whether it has an insertion point, it is the relationship between option elements in the flattened tree and the HTMLSelectElement’s data model (selectedIndex, etc.)
Comment 7 Dimitri Glazkov 2012-08-23 16:11:42 UTC
(In reply to comment #6)
> (In reply to comment #4)
> On reflection I think my beef is not with whether it has an insertion point, it
> is the relationship between option elements in the flattened tree and the
> HTMLSelectElement’s data model (selectedIndex, etc.)

Ah. the data model shouldn't need to worry about the flattened tree. It only looks at the children of <select>. Having an insertion point inside of a <select> doesn't seem to influence that in any way.
Comment 8 Dimitri Glazkov 2012-08-23 16:14:30 UTC
(In reply to comment #5)
> We should not add any special cases to Shadom DOM at this point. 
> Once the spec is otherwise stable, there could a yet another
> spec defining additions to HTML elements (if really needed).

Yup. That type of spec would be an awesome improvement for http://www.whatwg.org/specs/web-apps/current-work/multipage/rendering.html#bindings