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

Hi everyone, 

I am just new here but I would like to get some clarifications. Given that you need define the shadow root of a given custom-element, I am really confused on how the proposed way of defining it in a declarative way should be. All I am seeing right now is:

```
 <custom-a>
    <template newattribute> (or <shadowroot>)
      <img src='...'>
      <script src='...'>
    </template>
  </custom-a>
```

or 

```
<custom-a>
  <shadowroot>
    <slot></slot>
    <div></div>
  </shadowroot>
  <custom-b>
    <shadowroot>
      <slot></slot>
      <custom-c>
         <shadowroot>
            <slot></slot>
            <div></div>
         </shadowroot>
         <div></div>      
      </custom-c>
    </shadowroot>
  </custom-b>
</custom-b>
```

or 

```
<div-or-something>
  <template attach-shadow shadow-mode="open | closed">
    ...shadow content...
  </template>
</div-or-something>
```

But wouldn't this confuse us (or the browser) or when to just use `<custom-a>` or `<custom-b>` as a tag and when to add the shadow root definition of `<custom-a>`?

What if this happens while parsing the html document below?

```
<html>
<head>
</head>
<body>
<custom-a>
  <shadowroot>
     Hello <slot></slot>!
  </shadowroot>
</custom-a>

<custom-a>
  <shadowroot>
     Hi <slot></slot>!
  </shadowroot>
</custom-a>

<custom-a>
  World
</custom-a>
</body>
</html>
```

If we mixed the definition of a custom-element's shadow root in the light child of the custom-element, then would that mean we can replace it while parsing the html (which is good if you want to change the shadowroot), but would at least confuse when is the time the custom-element is being used and when is the time the custom-element is being defined.

Would this be a better case?

```
<html>
<head>
</head>
<body>

<!-- usage phase -->
<custom-a>
  World
</custom-a>

<!-- definition phase -->
<shadowroot tag="custom-a">
  Hello <slot></slot>!
</shadowroot>

<!-- or -->
<template shadowroot tag="custom-a">
  Hi <slot></slot>!  
</template>

</body>
</html>
```

At least it defines when a custom-element is being used (when it is really being used as a tag) and when it is being defined (when you explicitly want to attach a shadow dom to a particular custom-element by using a defined tag like shadowroot or extend the template tag)

Just my thoughts.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/dom/issues/510#issuecomment-330021330

Received on Sunday, 17 September 2017 04:56:34 UTC