Re: [whatwg/dom] `MutationObserver` flag to observe mutations in (open) shadow trees to facilitate polyfills of HTML syntax (Issue #1287)

WebReflection left a comment (whatwg/dom#1287)

To whom it might concern (underwhelming reactions there...)

just updated to v0.1.0:

* it never patches attachShadow twice
* it works with attachShadow in constructor (disconnected when created offline)
* it works with nested Shadow Roots (open or closed)
* it adds *closed* (if meant) ShadowRoots to the list of records with the target

I am not saying it's perfect, but all scenarios seem to be covered:

* node created offline ✅
* node already in the DOM with a `document` observed *ASAP* via `<script type="module">` (hence it should work on DOMContentLoaded too)
* roots are passed as records if closed because there wouldn't be otherwise any way to reach these ... this is useful for libraries that would like to boostrap components in there that will not otherwise show up in the records if the container has been created offline, making it the only new node added

It'd be lovely to have some feedback, hint me around uncovered cases, maybe tell me if this degrades in any meaningful way performance.

Accordingly to *Cursor*, but bear in mind it was me writing everything (except JSDoc TS), the only caveat around this "*polyfill*" is that Declarative ShadowDOM does not pass through `attachShadow` so in there stuff won't be observed.

I honestly think that's a desirable compromise because DSD is **server side territory** so that whoever creates the page is in charge of handling its own content and/or, eventually, expose / upgrade / manage the ShadowDOM accordingly.

Thanks in advance to whoever will try and feedback around this "*polyfill*", after all there were a few challenges (mostly RAM/relations related) but if I could tackle all of them with relative ease, I believe standard bodies wonderful experts could do the same ... remember the `:has(...)` selector concerns that faded away thanks to some brilliant mind that helped mitigating performance issues? We can do it here too!

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

Message ID: <whatwg/dom/issues/1287/4312556218@github.com>

Received on Friday, 24 April 2026 10:42:51 UTC