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

It might still be nice for a Custom Element to detect distribution (without leaking structure of a shadow root) because then with this knowledge it can trigger an event if it needs to. This is not possible with `slotchange` because there's no way for a `slot` to determine which event a distributed node should fire.

After thinking about this for a while, and after successfully [making my library compatible with ShadowDOM V1 including closed shadow roots](https://github.com/trusktr/infamous/issues/40), I still think the a solution to the need described in this issue would be invaluable because then I would be able to detect certain conditions that I can not otherwise detect without crazy hacks, in order to give the end user of my library helpful console messages like "Warning: Your motor-node#someID element does not work when distributed to such-an-such element. It must be distributed to a motor-scene or motor-node element.`

With `slotchange` and `assignedNodes`, I can only detect proper use cases where a shadow root is the root of one of my library's custom elements and when a slot is child of one of my library's custom elements and when one of my library's elements are connected or distributed directly to another element of my library. Detecting the other cases would be too hacky and expensive so far as I can imagine (involving hijacking attachShadow and traversing all shadow roots).

-- 
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-264333536

Received on Thursday, 1 December 2016 23:59:47 UTC