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

@hayatoito 

> Is slotchange for that really a useful event for web developers?

It's more useful for library authors.

> In real worlds, does removing slots (or its one of ancestors) from the tree happen frequently?

It's easy to imagine scenarios. Using our imagination or example, imagine a game. When the user's monster character gets to a higher skill level, it earns an extra hand. Objects like guns or tools could be placed into this new hand (i.e. slotted into this new slot). If the character is injured, maybe it's hand gets severed from battle, then the hand is removed (the slot is removed but the perhaps the gun remains in inventory).

```html
<monster-character>
  <weapon-rifle slot="hand-1">
  </weapon-rifle>
  <weapon-pistol slot="hand-2">
  </weapon-pistol>
  <weapon-knife slot="hand-3">
  </weapon-knife>
</monster-character>
```

> It would be great if we can see a concrete example of the current usage of a slotchange event listener. Do you know that?

In [`infamous`](https://github.com/trusktr/infamous), I use slotchange to detect the composed tree. Then I can traverse the composed tree to render a WebGL scene. Traversing the light tree is (obviously) naive, and will not work when users decide to compose my custom elements using shadow dom.

A-Frame mentioned they don't intend to support Shadow DOM... But, if they did, they would need to understand the composed tree in order to render that with Three.js. `slotchange` would be very handy for them if they want to add this feature now or in the future.

-- 
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#issuecomment-335346435

Received on Tuesday, 10 October 2017 03:05:17 UTC