- From: Andrea Giammarchi <notifications@github.com>
- Date: Sun, 30 Mar 2025 09:30:07 -0700
- To: whatwg/dom <dom@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
- Message-ID: <whatwg/dom/issues/736/2764636514@github.com>
WebReflection left a comment (whatwg/dom#736) ok, it might not be super clean but I've managed to write down what I had in mind: https://github.com/WebReflection/group-nodes#readme ... you can already test that via `import { GroupNodes } from 'https://esm.run/@webreflection/group-nodes'` and play around, here the main things: * patching [CharacterData](https://github.com/WebReflection/group-nodes/blob/main/src/character-data.js), [Element](https://github.com/WebReflection/group-nodes/blob/main/src/element.js), [DocumentFragment](https://github.com/WebReflection/group-nodes/blob/main/src/document-fragment.js) and [Node](https://github.com/WebReflection/group-nodes/blob/main/src/node.js) is relatively trivial, all engines need to know is that there is a *GroupNodes* variant of a *DocumentFragment* * writing down *GroupNodes* was less trivial, but the whole point is that this should not affect native DOM performances unless you create a *GroupNodes* reference * a *GroupNodes* is effectively a *DocumentFragment* **but** it's bound to its comments' boundaries ... these are never reachable via the fragment itself, before or after being live, but these are "*stamped*" live once the *GroupNodes* is appended * *GroupNodes* in *GroupNodes* just work ... actually there is no case/scenario where such instance cannot be ported around ... offline, live, in *ShadowDOM* and whatnot * there is no persistent/live tracking of anything .. those boundaries define the current state of that *GropuNodes* ... if somebody append a node in between boundaries, those are removed when the *GroupNodes* is removed or moved elsewhere when the reference is moved elsewhere * the user is the *owner* of the *GroupNodes* reference ... there's no way to overlap or clash with other similar references * the contract is that when a *GroupNodes* reference is created, its boundaries are flagged as *owned* (it's just a *WeakSet*) and nobody can reuse those nodes to create other *group nodes* I would be more than happy to explain all scenarios where this works, is desirable, it simplifies by far implementation around and it doesn't need live tracking of anything as the DOM is the DOM and anyone can break it in a way or another. As a matter of fact, every single *GroupNodes* operation checks indeed if its boundaries are *valid* and it throws out of the box if that's not the case (somebody removed one of those comments or broke everything via a Range and I think that's fine as we cannot prevent bad code to happen). I hope this sketched, yet I believe working, prototype of the *fragment bound to its surrounding comments* idea could help understanding where we are or what we are after (we as developers) ... the thing is kept as simple as possible and the main effort is only around the definition of that GroupNodes inherited accessors, currently [almost all covered](https://github.com/WebReflection/group-nodes/blob/main/src/group-nodes.js#L58), there are a few *TBD* around but all minor things, irrelevant for proposal to be considered or move eventually, if ever, forward. -- Reply to this email directly or view it on GitHub: https://github.com/whatwg/dom/issues/736#issuecomment-2764636514 You are receiving this because you are subscribed to this thread. Message ID: <whatwg/dom/issues/736/2764636514@github.com>
Received on Sunday, 30 March 2025 16:30:12 UTC