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

rniwa left a comment (whatwg/dom#736)

In terms of this proposal, [@dbaron's summary](https://github.com/whatwg/dom/issues/736#issuecomment-2450228044) provides two distinct design possibilities. It appears that most people are going after "Proposal B" in the summary, which is basically a real `Node` which appears in `childNodes`, etc... but ignored for the purpose of selector matching and other rendering APIs.

But the devil is in the details. Suppose we had an element `e_1` and `NodeGroup` (the new node type) was inserted under `e_1`. Then `e_1.childNodes[0]` will return the `NodeGroup` but what happens to `e_1.children[0]`. Would it return the first element child under `NodeGroup`? Or would it return `undefined` because there is no direct child of `e_1` which is an element. What happens if `NodeGroup` had another `NodeGroup` as a direct child. Would we be "unwrapping" nested `NodeGroup`s until we hit a real non-`NodeGroup` `Node`? In that case, this proposal is very much similar to DOM Part proposal we made. The only difference is whether `NodeGroup` appears as an actual Node or not.

Alternatively, are we accepting all those intermediary nodes as a part of the real DOM? In that case, this `NodeGroup` is much like a container element with `display: contents` with one notable difference being that this node can appear between any other element, e.g. between `tr` and `td`. Meanwhile, a selector like `tr > td` and `tr > td:nth-child(3)` probably want to skip/ignore over all those intermediary `NodeGroup` nodes. What happens to things like DOM events though? Are we dispatching events through these intermediary nodes (i.e. they're a part of the event path), which seems like a natural/expected behavior, or are we skipping them?

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

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

Received on Thursday, 27 March 2025 07:09:50 UTC