Re: [whatwg/dom] Meta: a list of side effects that would be impacted by state-preserving move (Issue #1270)

trusktr left a comment (whatwg/dom#1270)

> * Perhaps add a `movedCallback`, that has a default to call `disconnectedCallback` and `connectedCallback`?

Defaulting to calling `disconnectedCallback` and `connectedCallback` would provide no benefit though. We can just use `disconnectedCallback` and `connectedCallback`!

Instead, I think this would be a lot more useful:

```js
movedCallback(previousParent) {
  const newParent = this.parent

  // ...
}
```

otherwise with `disconnectedCallback` and `connectedCallback` custom elements will, by default, be destroying and re-creating things unnecessarily, which defeats the purpose of the atomic reparenting in the first place.

So `moveCallback` would be a **differentiator** that the elements was *not* disconnected, only moved.

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

Message ID: <whatwg/dom/issues/1270/2660772701@github.com>

Received on Saturday, 15 February 2025 06:36:09 UTC