W3C home > Mailing lists > Public > www-style@w3.org > February 2014

Re: Shadow DOM: Hat and Cat -- if that's your real name.

From: Tab Atkins Jr. <jackalmage@gmail.com>
Date: Tue, 4 Feb 2014 14:49:44 -0800
Message-ID: <CAAWBYDDD7xzH--YwqYkVsi_dncCOPAoW0ZnuPPQx4YN=k+=SQg@mail.gmail.com>
To: "Robert O'Callahan" <robert@ocallahan.org>
Cc: Sylvain Galineau <galineau@adobe.com>, "Edward O'Connor" <eoconnor@apple.com>, www-style list <www-style@w3.org>
On Tue, Feb 4, 2014 at 12:44 PM, Robert O'Callahan <robert@ocallahan.org> wrote:
> An expedient approach would be to allow selectors to penetrate the shadow
> DOM by default and in a future spec revision add the ability for component
> authors to opt out of this, along with introducing other features to support
> custom styling.

Oh gosh no.  Encapsulation by default is absolutely necessary to avoid
the pains of current jquery/etc components, the avoidance of which is
the entire point of Shadow DOM.

Plus, doing so requires more work than just "allowing" selectors to
pierce shadow boundaries.  The tree augmented with shadows is no
longer a plain tree - it's a tree of trees.  In particular, children
of an element may not be siblings of each other.  This causes all
sorts of weirdness - does :first-child match multiple children? - etc.

It also drastically reduces our ability to optimize.  With
encapsulation-by-default, you can ignore all the rules from the
outside world that don't include a shadow-piercer in their selector.
With piercing-by-default, you gain nothing, and have to resolve the
entire document's CSS against everything in the document.  That's a
terrible position to be in.

> The only argument I can think of against that is that the default is
> "unsafe" for component authors, who will unexpectedly find themselves in a
> deep hole later when they can't change anything their component without
> breaking pages. But that's not too bad; it's certainly no worse than the
> status quo, so at worst it's a missed opportunity.

It's far worse than just being "unsafe", as I partially outlined
above.  Piercing-by-default would render much of Shadow DOM's reason
for existing moot.

~TJ
Received on Tuesday, 4 February 2014 22:50:32 UTC

This archive was generated by hypermail 2.3.1 : Monday, 2 May 2016 14:39:18 UTC