On Feb 15, 2014, at 4:57 PM, Ryosuke Niwa <rn...@apple.com> wrote:
I wanted to mention that this handles other use cases besides selecting a random child which are impossible (or at least very awkward) with <content select=""> as presently defined:
(1) A container component that can hold an arbitrary number of children, and wraps each of its light DOM children in a piece of markup inside the Shadow DOM. Consider a <buttonbar> component that placed each child into a <button>, and styled them all specially:
Imagine it would render like this (explaining why separate individual <button> elements won't cut it).
(2) A component that expects alternate labels and corresponding items, wants to parent them into different boxes, but wants to make sure they remain corresponding.
<tabpane>.... lots of pictures of puppies ....</tabpane>
<tabpane>.... lots of pictures of kittens ....</tabpane>
<!-- no tab pane provided for this title yet -->
<tabpane>.... lots of pictures of bunnies ...</tabpane>
The component author would like this to render as a tabview with 4 tab labels at the top ("Puppies", "Kittens", "Sadness", "Bunnies") and 3 actual tab panes with one placeholder inserted: (the puppy pane, the kitten pane, a blank placeholder, the bunny pane).
But if my shadow DOM looks like this:
<div class=tab-label-bar><content select="tabtitle"></div>
<div class=tab-holder><content select="tabpane"></div>
Then the pictures of bunnies would line up with the "Sadness" label, and I don't have an easy way to add the placeholder anywhere but at the beginning or the end of the tab panes.
(3) An element that selects some of its children conditionally. Let's say you have an element that will select different children depending on what features the browser supports:
<case condition="Modernizr.webgl">Spiffy WebGL view goes here!</case>
<case condition="Modernizr.canvas">Passable 2-D canvas view goes here</case>
<case default>Oh noes! You need more browser features to use this site!</case>
The idea is to select in only exactly one of the cases - the first that matches. The others don't go into the shadow DOM. There isn't a great way to select only one of the "case" elements here (after having run the JS to evaluate which applies).
The SVG "switch" element does something similar, as does Modernizr's normal class-based mode of operation.
I hope these examples give more motivation for why programmatically binding an insertion point may be useful.
- [webcomponents] Imperative API for Insertion Points Ryosuke Niwa
- Re: [webcomponents] Imperative API for Insertion Po... Alex Russell
- Re: [webcomponents] Imperative API for Insertio... Ryosuke Niwa
- Re: [webcomponents] Imperative API for Insertio... Edward O'Connor
- Re: [webcomponents] Imperative API for Insertion Po... Ryosuke Niwa
- Re: [webcomponents] Imperative API for Insertion Po... Maciej Stachowiak