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

I'm maybe in the minory but I like ShadowDOM.

I like the encapsulation and the potential performance benefits possible today and in the future. Having a global style sheet space with tricks to scope component makes me feel uncomfortable. Lot's of performance and memory optimization are possible with ShadowDOM. Will we every get them I don't know but we at least we have a way out.

So naturally I'm positive about the proposal.

But I'm concern about the `<template>` use. Is that used for technical reason or is it really idiomatically correct? `<template>` tag are not visible and here you want them to be visible.

I would rather make shadowDOM available everywhere like:

(The use of '#shadowroot' is just to relate with what's in devtools today and the private class fields of js - the name is not important)

```html
<host-element>
    <#shadowroot>
        <style>shadow styles</style>
        <h2>Shadow Content</h2>
        <slot></slot>
    </#shadowroot>
    <h2>Light content</h2>
</host-element>
```

or

```html
<div>
    <#shadowroot>
        <style>shadow styles</style>
        <h2>Shadow Content</h2>
    </#shadowroot>
</div>
```

(Open by default)

+1 for @justinfagnani adoptedsheet inclusion because that's what you want with styles and not inline them everywhere

```html
    <#shadowroot adopted-styles="style-one style-two">
        <h2>Shadow Content</h2>
    </#shadowroot>
```

You can still do
```html
<template>
    <#shadowroot>
        <style>shadow styles</style>
        <h2>Shadow Content</h2>
        <slot></slot>
    </#shadowroot>
</template>
```
If you want to have a template, makes perfect sense.

----

Regarding SSR, I think this is what we want.

```html
<my-element>
    <#shadowroot>
        <style>shadow styles</style>
        <h2>Shadow Content</h2>
    </#shadowroot>
</my-element>
```

As per the Custom Element Specs, until `<my-element>` is defined, the browser will render what is inside the Custom Element. Once the Custom Element is defined it will replace or upgrade it. You can do SSR, hydration, skeletons, placeholders, you name it.

It's native, IMO relatively simple to explain and understand and inline with existing semantics.
I would be very happy with this. 

My 2 cents

-- 
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/831#issuecomment-586146119

Received on Friday, 14 February 2020 08:12:07 UTC