-
Couldn't load subscription status.
- Fork 318
Description
What problem are you trying to solve?
As a custom element author, you have a couple of mechanism available to you to detect changes in slotted elements:
- The
slotchangeevent MutationObserver
For most cases slotchange is enough, but if you want to detect changes to attributes for example, you need MutationObserver.
Now as long as you have no nested slots, then everything is fine. However, as soon as you have a nested slot, MutationObserver also no longer works. For example:
<x-foo>
<template shadowrootmode="open">
<x-bar>
<template shadowrootmode="open">
<slot></slot>
</template>
<slot></slot>
</x-bar>
</template>
<button>Button</button>
</x-foo>In the above scenario <x-bar> would have a MutationObserver that monitors it's own host element. It will not fire when the button changes or a second button is added.
I propose a new option to the MutationObserver.observe() method called flatten or composed (name TBD) that would instruct the observer to also observe any slotted children of any slots it is observing.
What solutions exist today?
None
How would you solve it?
New flatten or composed option to MutationObserver.observe()
Anything else?
No response