Re: [w3c/webcomponents] How can a custom element detect when it is transcluded into a shadow tree (slotchange)? (#504)

Oops, nevermind. So parents observing children works in order to detect invalid children (and to detect invalidly distributed children when parent contains a slot and is in a shadow tree).

But, if a child is distributed into any element other than my custom elements (for example, on of my `<motor-node>` elements is distributed into a `<div>` or some other non-motor element), then there's no way for the distributed child to observe that it's parent is invalid if the Shadow tree is closed.

The only solutions I can think of right now are:

1. Require shadow trees to be open. The children can easily observe parents.
1. Add a new `distributedCallback` to the CustomElements API, and ensure that slotchange fires before a distributed child's distributedCallback is fired. This option would allow a parent to make a connection with the child in slotchange. Then, if no connection is made, a child would be able to detect that no connection was made inside of it's distributedCallback.

I've been thinking about this for weeks (in the back of my head while I work on other things) and can't find a solution.

@treshugart @hayatoito @rniwa Any ideas or 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/w3c/webcomponents/issues/504#issuecomment-228502080

Received on Saturday, 25 June 2016 02:20:57 UTC