[w3c/webcomponents] Discussion: child elements cannot determine whether they are "active" or not (#817)

In the process to optimize a web component, we often encounter a situation where child elements from the light-dom are unable to determine, reliable, if they are slotted or not into its parent shadow. Abstract example:

```html
    <x-foo>
        <x-bar>
            <x-baz></x-baz>
        </x-bar>
    </x-foo>
```

Depending on the state of `<x-foo>`, it attaches the `<slot>` element or not into its shadow, causing `<x-bar>` to be slotted accordingly.

And whether or not that happens, is not observable in `<x-bar>` and `<x-baz>` without doing some gymnastics that are not trivial. Considering that `<x-bar>` and `<x-baz>` could be very complex, and heavy, e.g. (content of a tab, or content for a panel, etc), it will be interesting to explore a way for those elements to get a notification when they become slotted (part of the flat tree). At the moment, it seems that checking for `this.assignedSlot` is good enough, but unfortunately it is a pull process, and if you get slotted after insertion into the light-dom, you have no way to tell as far as I can tell. 

This will be more self-evident if we ever introduce manual slotting.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/w3c/webcomponents/issues/817

Received on Thursday, 23 May 2019 22:16:26 UTC