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

WebReflection left a comment (whatwg/dom#736)

if anyone is interested to know what's a simplified hydration variant ... a range could select a start comment (*setStartBefore*) and and end content (*setEndAfter*) and validate on `range.createGorupNodes()` which returns a new *GroupNodes* via *extractContents()*, comments nodes removed and bound to the rest of the fragment, and from that time on any DOM operation that recieves or uses that *group* as reference would move such *range* around, prepend, append, insertBefore, remove and whatnot.

I haven't patched the *Range* prototype but it could be a nice addition to the idea so that issues around comments being already owned as *group* would disappear, keeping the constraints *one group -> two unique boundaries*.

When offline, all operations through that instance work exactly the same as in *document-fragment* but once there is a parent all operations are confined in between those boundaries.

If there is an elephant in the room about my implementation is that *range* itself does not provide many ways to work within itself (`insertNode` and not much else, no query selector, no append, prepend, insertBefore, nothing from the rest of the DOM API) and if there was such way my implementation would've been *way easier* to write and performance likely better, as right now to grab nodes I need to loop `nextSibling` between those boundaries every single time via JS.

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

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

Received on Monday, 31 March 2025 05:42:51 UTC