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

FrameMuse left a comment (whatwg/dom#736)

## `NodeGroup`

Let me try to picture how the `NodeGroup` looks right now.

### Signature

```ts
class NodeGroup implements Node, ParentNode, ChildNode, NonDocumentTypeChildNode {
  constructor(public readonly name: string) { }
}
```

- No augmentations
- Nothing special added

### Behavior

**Rules**
- Conventional behavior of a `ChildNode` and `ParentNode`
- Inherited behavior of `DocumentFragment` children - any type of nodes can be placed together, it won't error or be forcefully "fixed" and etc. thus entirely repeating `DocumentFragment` **children containing** behavior.

**Exclusion of rules**
- Bypasses box models (just like `display: contents`)
- Bypasses layouting (just like `display: contents`)
- Bypasses CSS selectors

_Comparing this behavior to other instances, it would be pretty much the same as Figma Group Node._

### Interpretations

- `NodeGroup` as a range of nodes, where there is a starting node and ending node - accenting nodes **between** those two.
- `NodeGroup` as a list of nodes, where multiple nodes randomly stored under a parent - accenting **some** nodes.
- `NodeGroup` as encapsulated area of nodes - accenting **ownership** of a certain place in the document.

The interpretations give:

1. Understanding of where/how `NodeGroup` could be applied
2. Potential possibilities of further development - like `Range.prototype.groupNodes` and etc.
3. Chance to see `NodeGroup` from other sides

### Devtools

In the inspector, nodes that are grouped (under `NodeGroup` instance) would be indented and displayed inside a visible block (e.g. with a name `MyGroup`), which could be grayed out emphasizing it's "transparency". It would have visual boundaries, something like in @WebReflection's [prototype](https://github.com/WebReflection/group-nodes), which are selectable just like elements - selecting each boundary would lead to assigning the `NodeGroup` instance to `$0`.

---

Hopefully, I'm aligned with people, if something's off, please tell me I will update this comment.

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

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

Received on Tuesday, 15 April 2025 11:11:30 UTC