[whatwg/dom] Shadow: Specify when `slotchange` fires (#447)

Safari, Chrome and ShadyDOM currently exhibit different behavior when `slotchange` does and does not fire. As far as I understand the spec, it is not precisely spec’d, meaning all these current behaviors are technically spec compliant, but can be very frustrating for developers.

[Demo 1](https://jsbin.com/nomupo/3/edit?html,console,output): The parser creates a CustomElement that  uses ShadowDOM with slots
[Demo 2](https://jsbin.com/sizehoz/6/edit?html,console,output): The same element in an upgraded

**Which browser fires `slotchange`?**

| | Parser Create demo | Upgrade demo |
|-|----|---|
|Chrome| Fire | No fire |
|Safari| No fire | No fire |
|ShadyDOM| Fire | Fire |

(ShadyDOM was tested using Firefox).

While **my main concern is consistency across browsers**, I like ShadyDOM’s behavior best in terms of DX as it is consistent with how `attributeChangeCallback` in that it fires upon initialization. This would allow developers to have their update logic in the `slotchange` handler and they wouldn’t need to manually detect silently slotted elements in `connectedCallback()`.

/cc @hayatoito

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

Received on Wednesday, 26 April 2017 10:57:33 UTC