Re: [webcomponents] Auto-creating shadow DOM for custom elements

On Thu, Dec 5, 2013 at 5:37 PM, Ryosuke Niwa <rniwa@apple.com> wrote:

> Hi,
>
> Given that many important/natural use cases of custom elements involve
> shadow DOM,
> can we add a flag to auto-create shadow DOM for custom elements?
>
> In particular, can we add "template" as the third argument to
> document.register so that
> when a custom element is "instantiated", the specified template is
> automatically closed
> and inserted into a shadow DOM of the custom element.
>
>
Can you explain the advantage of this? It saves one line of code:

this.createShadowRoot().appendChild(document.importNode(template.contents));

I don't see how pushing that one line down into the browser is helping
anyone. Web components are part of the extensible web concept where we
provide a minimal subset of features necessary for opinionated frameworks
to build things on top. Supporting <template> in document.register is
easily done in script, so I believe it's better left to developers as
they're better at building frameworks than we are.

In either case, that's something we can always add later so it shouldn't
stand in the way of the current spec.

- E

Received on Saturday, 7 December 2013 03:42:56 UTC