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

> @noamr Since both sides seems to be right, and by what I can see here the major issue is throwing (as try/catch is slow), would it be possible to make the method return true/false if the move operation was succeed/failed? (maybe the name could be changed to tryMove or something similar). In that way I believe both ends will be having what they want: No error will be thrown, the user will be able to do whatever they want if the operation failed (throw, insertBefore), no "magic" things will happen, and you will still be able to extend this functionality in the future without any risks of breaking existing code.

This function already returns the new node, like `insertBefore`.
As an alternative to throwing, the user code can make the same checks as the browser/spec does. [here for chromium](https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/core/dom/node.cc;l=764?q=dom%2Fnode.cc) and in the spec PR.

btw this is where this whole thing was discussed with all the browser vendors:
https://github.com/whatwg/meta/issues/326#issuecomment-2377500295


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

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

Received on Friday, 22 November 2024 17:28:55 UTC