Re: [whatwg/dom] Declarative Shadow DOM (#831)

@nolanlawson ,
> > the "overhead" of creating the template document and moving contents around

> After discussion with @smaug---- on this topic, this seems to be the main concern.

the externalizing template and making it attached to the element with light DOM payload  would solve the problem of moving template. It `template` reside in the page outside of component, there is no need to move or mutate it.  DSD just need to provide declarative way of `attachShadow()` to this external to the component template. 

Here is just few ideas how to associate component with external template 
* via `template` attribute on component:
```html
<template id="my-template">
    <details><summary><slot name="heading">🍒</slot></summary>
        <slot name="details">fruits</slot>
    </details>
</template>
<section template="my-template">
     <b slot="heading">🥕</b><i slot="details">Carrot</i>
</section>
``` 
* via `for` attribute on template( worse as does not allow multiple instances ):
```html
<template for="my-component">
    <details><summary><slot name="heading">🍒</slot></summary>
        <slot name="details">fruits</slot>
    </details>
</template>
<section id="my-component">
     <b slot="heading">🥕</b><i slot="details">Carrot</i>
</section>
``` 

* As embedded template in current implementation even worse of `for` version as does not separate template from component:

```html
<section>
    <template shadowroot="open">
        <details><summary><slot name="heading">🍒</slot></summary>
              <slot name="details">fruits</slot>
      </details>
    </template>
    <b slot="heading">🥕</b><i slot="details">Carrot</i>
</section>
``` 


-- 
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/dom/issues/831#issuecomment-1253504651

You are receiving this because you are subscribed to this thread.

Message ID: <whatwg/dom/issues/831/1253504651@github.com>

Received on Wednesday, 21 September 2022 10:23:35 UTC