Re: Encapsulation and defaulting to open vs closed (was Re: Shadow DOM Encapsulation)

On Thu, Feb 6, 2014 at 5:45 PM, Boris Zbarsky <> wrote:
> On 2/6/14 8:28 PM, Tab Atkins Jr. wrote:
>> Of course it's possible to build Type 2 on top of Type 1 - just delete
>> or override the .shadowRoot accessor from the element.
> That's not true given querySelector("foo ^^ bar"), as far as I can tell,
> which was what Maciej was saying about the proposed default behavior of ^^.

It's not true if Maciej's Type 2 is used, either, at least as it's
been proposed before.

Previous proposals for this kind of thing were that shadow DOM trees
were constructed explicitly, but were just independent objects; the
host object knows what its shadows are, but doesn't expose them in any
way.  If script wants to expose them, it puts them on some expando of
its choice, with convention hopefully dictating common patterns.

With this, either "foo ^ bar" still works, or it doesn't.  If it
doesn't work, then there's no way to opt it into working on your own.
You have to add a brand-new explicit switch in the magic side of the
API that makes the shadow tree "open", presumably for both JS and CSS.

You may recognize this as the *exact inverse* of what we've talked
about for building Type 2 on top of Type 1 (having a switch that
closes off a shadow root, so we can then selectively expose things to
CSS via some other method).  There's no way to do a full-fidelity
reproduction of either type on top of the other; you can fake it to
some extent, but ultimately the two models are slightly incompatible,
and need an additional primitive to really switch between them.  (This
can probably be chalked up to the fact that CSS is fairly hostile to
polyfills, unlike almost all of JS.)


Received on Friday, 7 February 2014 02:04:24 UTC