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

keithamus left a comment (whatwg/dom#1287)

I was going to raise a new issue but perhaps we can pivot this issue slightly; observing open shadow trees might be a bold step forward - but perhaps a "minimum viable solution" would be to instead just be notified _when_ an element gets a shadowroot, so that you can then observe the shadowroot if it's open, e.g. 

```js
const observer = new MutationObserver(records => {
  for (record of records) {
    if (record.type == 'attachShadow' && record.target.shadowRoot) {
      observer.observe(record.target.shadowRoot, {
        attachedShadowroots: true,
        subtree: true,
        childList: true
      })
    }
  }
});
observer.observe({
  attachedShadowroots: true,
  subtree: true,
  childList: true,
});
```

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

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

Received on Wednesday, 12 November 2025 09:00:24 UTC