Re: [webcomponents] Need "slotting changed" event (#288)

No, checking this condition is pretty easy & efficient since you can determine whether a node belongs to a given slot or not in O(1).  Essentially, each shadow root needs to store the names of all slots it contains in a hash set/map.  When its host' children changes, it can notify the shadow root that the slot assignments have changed for a specific name / default slot (keep repeating this process if the slot's parent also has a shadow root if you wanted to get notified of changes in distributed nodes).

Now, at the end of micro task, you visit all those shadow roots that have been notified of such potential changes and those that do have relevant event listeners.  If the slot element had been inserted or removed from a given shadow root, you may need to resolve the first slot for each slot name in O(n).  Otherwise, dispatch the event for each slot for which the shadow root had been notified of the change in its node assignments.

Having said that, I'm not opposed to running this at the end of the task (before painting essentially) although that might be painfully late for some use cases.

---
Reply to this email directly or view it on GitHub:
https://github.com/w3c/webcomponents/issues/288#issuecomment-176634744

Received on Friday, 29 January 2016 08:17:22 UTC