Re: [whatwg/dom] Proposal: a DocumentFragment whose nodes do not get removed once inserted (#736)

FrameMuse left a comment (whatwg/dom#736)

@robbiespeed 

> I wasn't suggesting that `Node` should have 2 parents, that's precisely why I clarified that `parentNode` should be `null` when the nodes in the group are not attached to a parent node in a DOM tree. `NodeGroup` is never a parent it's more like a `Range`, and nodes should be able to be part of many groups just like they can be with ranges.

`NodeGroup` **IS** a parent, since you mentioned it is purely a `Node` with children, which makes a `Parentnode`, which as you mentioned a strong benefit for this proposal (it reuses existing interfaces).

If considering that `NodeGroup` is **NOT** treated as a parent, it introduces confusion:
- `NodeGroup` has `childNodes`, where they don't share the same state, they go around the `NodeGroup` and retrieve the parent of the parent.
- An element that contains `NodeGroup` doesn't include `children` of the `NodeGroup` (only direct ones), and in `childNodes` the `NodeGroup` is referenced directly (not being unwrapped).

There is `documentOwner` property, which tells if a node is by any means attached to any document, not just a parent. So making `parentNode` act differently breaks "the strong benefit" and creates problems for developers (i.e. you can test `parent` property to tell if `replaceWith` will work, in your case it will make developers create additional maps to test elements groups, which introduces more complexity).

Yes, `NodeGroup` is similar to `Range` but it also true for `DocumentFragment`, we can find even more similar structures because IMO it's pretty simple concept, which is based on what is already in the standard.

Comparing things is cool, I like it, here's my opinion about why `parentNode`, it should be untouched as a continuation of this proposal:
https://github.com/whatwg/dom/issues/736#issuecomment-2746360903

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

Message ID: <whatwg/dom/issues/736/2760606236@github.com>

Received on Friday, 28 March 2025 09:01:07 UTC