- From: Lea Verou <notifications@github.com>
- Date: Fri, 12 Dec 2025 12:48:52 -0800
- To: whatwg/dom <dom@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
- Message-ID: <whatwg/dom/issues/533/3648097899@github.com>
LeaVerou left a comment (whatwg/dom#533)
> > It seems that instead what most use cases need is to observe (a) `ownerDocument` changes and (b) `parentNode` changes.
> > Then we can get all the existing custom element lifecycle hooks:
> >
> > * `connectedCallback()` β `ownerDocument` goes from `null` to a non-null value
> > * `disconnectedCallback()` β `ownerDocument` changes from a non-null value to `null`
>
> `ownerDocument` is never `null` so this won't work.
Ah, right, d'uh! π€¦π½ββοΈ
Now Iβm wondering if we need a property that works like thisβ¦ π
Basically something like:
```js
get document () {
let root = this.getRootNode({ composed: true });
return root.nodeType === Node.DOCUMENT_TYPE ? root : null;
}
```
Whether such a DOM property exists or not, we _could_ introduce a `document` option that works this way.
Or, alternatively, a `root` option that lets you observe changes to either the composed root, the tree root, or both.
That actually seems to be even more broadly useful than what I was proposing above.
--
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/dom/issues/533#issuecomment-3648097899
You are receiving this because you are subscribed to this thread.
Message ID: <whatwg/dom/issues/533/3648097899@github.com>
Received on Friday, 12 December 2025 20:48:56 UTC