Re: Imperative API for Node Distribution in Shadow DOM (Revisited)

On Tue, Apr 28, 2015 at 6:18 AM Ryosuke Niwa <rniwa@apple.com> wrote:

>
> > On Apr 26, 2015, at 6:11 PM, Hayato Ito <hayato@chromium.org> wrote:
> >
> > I think Polymer folks will answer the use case of re-distribution.
> >
> > So let me just show a good analogy so that every one can understand
> intuitively what re-distribution *means*.
> > Let me use a pseudo language and define XComponent's constructor as
> follows:
> >
> > XComponents::XComponents(Title text, Icon icon) {
> >   this.text = text;
> >   this.button = new XButton(icon);
> >   ...
> > }
> >
> > Here, |icon| is *re-distributed*.
> >
> > In HTML world, this corresponds the followings:
> >
> > The usage of <x-component> element:
> >   <x-components>
> >     <x-text>Hello World</x-text>
> >     <x-icon>My Icon</x-icon>
> >   </x-component>
> >
> > XComponent's shadow tree is:
> >
> >   <shadow-root>
> >     <h1><content select="x-text"></content></h1><!-- (1) -->
> >     <x-button><content select="x-icon"></content></x-button><!-- (2) -->
> >   </shadow-root>
>
> I have a question as to whether x-button then has to select which nodes to
> use or not.  In this particular example at least, x-button will put every
> node distributed into (2) into a single insertion point in its shadow DOM.
>
> If we don't have to support filtering of nodes at re-distribution time,
> then the whole discussion of re-distribution is almost a moot because we
> can just treat a content element like any other element that gets
> distributed along with its distributed nodes.
>
>
x-button can select.
You might want to take a look at the distribution algorithm [1], where the
behavior is well defined.

[1]: http://w3c.github.io/webcomponents/spec/shadow/#distribution-algorithms

In short, the distributed nodes of <content select="x-icons"> will be the
next candidates of nodes from where insertion points in the shadow tree
<x-button> hosts can select.




> - R. Niwa
>
>

Received on Monday, 27 April 2015 21:39:08 UTC