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

On Wed, Apr 29, 2015 at 4:15 PM, Dimitri Glazkov <dglazkov@google.com> wrote:
> On Mon, Apr 27, 2015 at 8:48 PM, Ryosuke Niwa <rniwa@apple.com> wrote:
>> One thing that worries me about the `distribute` callback approach (a.k.a.
>> Anne's approach) is that it bakes distribution algorithm into the platform
>> without us having thoroughly studied how subclassing will be done upfront.
>>
>> Mozilla tried to solve this problem with XBS, and they seem to think what
>> they have isn't really great. Google has spent multiple years working on
>> this problem but they come around to say their solution, multiple
>> generations of shadow DOM, may not be as great as they thought it would be.
>> Given that, I'm quite terrified of making the same mistake in spec'ing how
>> distribution works and later regretting it.
>
> At least the way I understand it, multiple shadow roots per element and
> distributions are largely orthogonal bits of machinery that solve largely
> orthogonal problems.

Yes.  Distribution is mainly about making composition of components
work seamlessly, so you can easily pass elements from your light dom
into some components you're using inside your shadow dom.  Without
distribution, you're stuck with either:

* avoiding <content> entirely and literally moving the elements from
the light dom to your shadow tree (like, appendChild() the nodes
themselves), which means the outer page no longer has access to the
elements for their own styling or scripting purposes (this is
terribad, obviously), or
* components have to be explicitly written with the expectation of
being composed into other components, writing their own <content
select> *to target the <content> elements of the outer shadow*, which
is also extremely terribad.

Distribution makes composition *work*, in a fundamental way.  Without
it, you simply don't have the ability to use components inside of
components except in special cases.

~TJ

Received on Wednesday, 29 April 2015 23:38:34 UTC