Re: [w3c/webcomponents] slotchange event should not bubble (#571)

> It was somewhat intentional so folks could make easier use of it with event delegation. I don't feel strongly though.

I think the problem here is that `slot` inside another `slot`.  Because bubbling events can will get into a shadow tree when its bubbling target is assigned to a slot.

For example, if a slot (A) outside a shadow tree (X) gets a new assignee, `slotchange` event fired on that slot (A) will bubble into another shadow tree (Y) attached on an ancestor of (A) if there is another slot (B) in (Y).  Then, we will fire the second `slotchange` event on (B).  So if you have an event listener added on (B), you end up observing `slotchange` twice once for when it was fired on (A) and another for itself.  We can get arbitrarily many duplicate `slotchange` events as you nest more shadow trees.

An alternative solution for this problem is to make a single bubbling `slotchange` event fired only at the slot to which a node was assigned.  Because this event will bubble, every slot which gets affected by this slot assignment will get notified.  This has a nice feature that one can observe all slot changes in a shadow tree at its `ShadowRoot`.

-- 
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/571#issuecomment-248266363

Received on Tuesday, 20 September 2016 10:45:16 UTC