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

it's been mentioned that `moveBefore(newNode, refNode, booleanTrap)` is undesired and I wonder **if** this API can at least be changed to be `moveBefore(newNode, refNode?, { fallback })` where the third argument, as object, could have a `fallback` field, or any other better name, to suggest the node should be *inserted* before, if no `move` operation can be performed.

If `fallback` as boolean is not cool (but it's fast, simple, and memory friendly), it could at least be a method that forwards arguments:

```js
parent.moveBefore(
  knownNode,
  refNode?,
  {
    fallback(knownNode, refNode?) {
      return this.insertBefore(knownNode, refNode);
    },
    // OR ...
    fallback: (parent, knownNode, refNode?) => {
      return parent.insertBefore(knownNode, refNode);
    }
  }
)
```

If such third option is not passed along, let it throw, if it's there, use that `fallback` without throwing.

If the `moveBefore` as it's landing won't throw on extra arguments then that perfect name for that API is lost in effectiveness and meaning so that, if even this extra argument as object is not desired, let's think about a better name than `moveBefore` because right now this should be named `moveBeforeMaybeAndThrowIfNotPossible` which would better represent the API functionality.

/cc @annevk @noamr thoughts?

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

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

Received on Monday, 25 November 2024 08:51:02 UTC