MutationObserver
flag to observe mutations in (open) shadow trees to facilitate polyfills of HTML syntax
#1287
Labels
addition/proposal
New features or enhancements
needs implementer interest
Moving the issue forward requires implementers to express interest
topic: shadow
Relates to shadow trees (as defined in DOM)
What problem are you trying to solve?
It is currently exceedingly difficult (and slow) to implement polyfills of certain features that affect HTML syntax across both light and shadow DOM because it requires observing mutations in shadow trees as well, which is currently incredibly difficult, and all solutions have prohibitive performance.
Some examples:
What solutions exist today?
The current options are:
HTMLElement.prototype.attachShadow()
with code that callsmutationObserver.observe()
on it, like so:shadowRoot
and callobserve()
on that too. Loop over all existing elements and attach mutation observers to the shadow roots of those with one.As you can see, all of these are pretty terrible. They are slow, obtrusive, and wasteful. Can we do better?
How would you solve it?
Option 1
This is the most straightforward, lowest effort option: Simply add a new option to
MutationObserverInit
to observe (open) shadow trees. Name TBB, some ideas might beshadow
,shadowRoots
.The MVP could be a boolean option, which could later be extended to more granularity (e.g. how many levels deep? What types of shadow trees (
open
,open-stylable
etc)).Option 2
It could be argued that
MutationObserver.prototype.observe()
is the wrong tool for the job. It was designed to observe mutations under a specific root, and has been since contorted to cater to these types of use cases. Perhaps a different method could be used to signal "observe this everywhere you can", e.g.MutationObserver.prototype.globalObserve()
.Anything else?
No response
The text was updated successfully, but these errors were encountered: