- From: Andrea Giammarchi <notifications@github.com>
- Date: Wed, 03 Apr 2024 06:26:55 -0700
- To: whatwg/dom <dom@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
- Message-ID: <whatwg/dom/issues/1270/2034610675@github.com>
> Mutation observer: potentially reflect that there was a move It's already easy to fail behind MutationRecords order (added VS removed, which to check first? I check removed first and update the logic synchronously for libraries which goal is to reflect *connected* and *disconnected* behavior) so this would be awesome to tackle and I see only two ways to do so: * both removed and added nodes lists refer to the same node with an extra `moved` boolean value (safe as it's `undefined` and considered always `false` to date, if ever even checked) * movedNodes list enters the game with optionally a `from` and `to` references for the nodes To be honest, this logic could be easily polyfilled too by checking the `parentNode` and `isConnected` properties of any removed node but if handled natively people would be surely happier ... the *move* operation is key to avoid tons of clean-up and events dispatching for something that maybe needs again, once reconnected, to bootstrap tons of stuff so it's not only the browser insertions/removals steps we all win, if less, it's a huge ecosystem of libraries that do a lot of work on disconnected and connected so I hope this MO related story will be as successful as the idea behind moving. > Custom elements ... Perhaps add a movedCallback, that has a default to call disconnectedCallback and connectedCallback? That would be the least surprise and fully backward compatible so I am overly :+1: with the movedCallback idea and its defaulting to current behavior: disconnected + connected This helps Web Components libraries authors to migrate while browsers adoption increase so it feels like a no-brainer to me and I hope it will be welcomed by others too. -- Reply to this email directly or view it on GitHub: https://github.com/whatwg/dom/issues/1270#issuecomment-2034610675 You are receiving this because you are subscribed to this thread. Message ID: <whatwg/dom/issues/1270/2034610675@github.com>
Received on Wednesday, 3 April 2024 13:26:59 UTC