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

On Fri, Dec 6, 2013 at 1:37 AM, 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

I guess you mean automatically cloned?

This does seems like a nice suggestion, as an optional parameter, the
cloning code is repeated
in most examples and it would be nice to remove this boilerplate.

> and inserted into a shadow DOM of the custom element.
>
> e.g. using ES6 class syntax:
>
> <template id=myButtonTemplate>
> <button>Hi!</button>
> </template>
> <script>
> class MyButton extends HTMLElement {
> ...
> }
> document.register('my-button', MyButton, myButtonTemplate);
> </script>
>
> Given that the shadow DOM specification is relatively stable if we constrain
> ourselves to
> only custom elements (i.e. ignoring all builtin elements), adding this
> mechanism will allow
> us to move the custom elements and shadow DOM specifications forward without
> risking
> to expose the general API for attaching shadow DOM to the Web.
>
> - R. Niwa
>

Received on Friday, 6 December 2013 09:25:38 UTC