Re: [whatwg/dom] Atomic move operation for element reparenting & reordering (Issue #1255)

Just to confirm my understanding:

The whole point here is to have the option to move a node without having to go through undesired disconnect/connect steps (which can discard state). Iff a node is not connected to the document that it's trying to move to, it's not possible to avoid the connect step, so an atomic move operation can't happen. To reflect this, `moveBefore()` throws. It will never throw for cases where state is possible to preserve. In a correctness sense, this is in the same spirit as the rest of the manipulation apis.

The problem is for library code where you would have to check every node that you're moving around to see if it was removed by someone else or something. In these cases, it's pointless to care whether it can be moved with or without (dis)connections, as you're really just declaring a desired DOM fragment. Any nodes that aren't already in the tree don't have any state to preserve anyways.

In the same sense that the newer manipulation functions have replaced `insertBefore()`, there needs to eventually be "soft" versions that just attempt to use atomic movement if they can. The painful part is that `before()`/`replace()`/`prepend()`/`replaceChildren()`/`append()`/`after()` already have the shortest names lol.

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

Message ID: <whatwg/dom/issues/1255/2495282250@github.com>

Received on Saturday, 23 November 2024 03:54:07 UTC