- From: Valery Zinchenko <notifications@github.com>
- Date: Fri, 12 Dec 2025 13:00:18 -0800
- To: whatwg/dom <dom@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
Received on Friday, 12 December 2025 21:00:22 UTC
FrameMuse left a comment (whatwg/dom#533)
@LeaVerou I think you misinterpret it, with `DOMParser` you create a brand new document, thus you have all the elements are "connected". `isConnected` is true only when it's connected to a document, so
```js
div = document.createElement("div")
div.append(123)
div.childNodes[0].isConnected // => false
document.body.append(div)
div.childNodes[0].isConnected // => true
```
though `ownerDocument` will stay the same.
So why we need connection (`isConnected`) observer? When an element is disconnected, we want any associated subscriptions to be unsubscribed and when it's connected - subscribe back. Another use-case is to enforce placement of an element as you can track where it's connected/disconnected from and add it back - this particular use-case can solve fundamental issues for "fragments".
--
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/dom/issues/533#issuecomment-3648125540
You are receiving this because you are subscribed to this thread.
Message ID: <whatwg/dom/issues/533/3648125540@github.com>
Received on Friday, 12 December 2025 21:00:22 UTC