Re: [whatwg/dom] Make it possible to observe connected-ness of a node (#533)

FrameMuse left a comment (whatwg/dom#533)

@justinfagnani Maybe I got you wrong, is this how it should work?
```js
const observer = new MutationObserver(entries => console.log(entries[0].connection))

const node = new Text("123")
observer.observe(node, { connection: true })

document.body.append(node) // => true
node.remove() // => false
```

Then I disagree. I personally think that connection is not mutation of a connected node (but a parent or document), it would be ambiguous to add it this way. The current `MutationObserver` is very on point - observe listed mutations **OF** these nodes. But in case of adding `connection` option, it goes a long way: observe mutations of all nodes, to tell if this is related to the observed node and see if it's connected or not.

So if it's already doing `childList` and `subtree` anyway, why making it ambiguous if we can introduce a new thing that just extends `MutationObserver`?

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

Message ID: <whatwg/dom/issues/533/2840902688@github.com>

Received on Wednesday, 30 April 2025 06:08:37 UTC