Re: [whatwg/dom] Introduce `moveBefore()` state-preserving atomic move API (PR #1307)

Would it be possible to have this method fallback to `insertBefore` if the conditions for an atomic move are not met? 

Without this, in practice it seems likely that users will need to write a boilerplate function that tests the 2 nodes for `isConnected` before calling. 

```js
const moveOrInsertNode = (container, node, ref_node = null) => {
 const canMove =  (container.isConnected && node.isConnected && (!ref_node || ref_node.parentNode === container);
  return canMove ? container.moveBefore(node, ref_node) : container.insertBefore(node, ref_node);
}
```

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

Message ID: <whatwg/dom/pull/1307/c2491906616@github.com>

Received on Thursday, 21 November 2024 17:55:47 UTC