Comments (4)
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'sundefined
and considered alwaysfalse
to date, if ever even checked) - movedNodes list enters the game with optionally a
from
andto
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 👍 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.
from dom.
I believe this would also affect being-rendered, whose exhaustive implications I am not sure.
- At least
<object>
and<embed>
1 would be affected. - It might have effect on
<img>
element that allow auto-size, though I'm really not sure here. - That might also affect
<select>
and<input>
elements on whichshowPicker()
has been called, keeping some pickers alive.
Footnotes
from dom.
I believe this would also affect being-rendered, whose exhaustive implications I am not sure.
- At least
<object>
and<embed>
1 would be affected.- It might have effect on
<img>
element that allow auto-size, though I'm really not sure here.- That might also affect
<select>
and<input>
elements on whichshowPicker()
has been called, keeping some pickers alive.Footnotes
Thanls, added these!
from dom.
I created a demo that tries to capture all these scenarios: https://state-preserving-atomic-move.glitch.me
from dom.
Related Issues (20)
- Atomic move operation for element reparenting & reordering HOT 43
- "connected" should be defined for all kinds of nodes HOT 1
- Ability to reset an AbortSignal.timeout HOT 3
- Add extend and modify methods for the Range object
- Add an optional options dictionary to `closest` to allow jumping across shadow boundaries HOT 1
- Efficient DOM Removal with the removeElement Function
- Steps of removing a node definition about live range do not match with browsers if the range is in a shadow DOM and the shadow itself is removed HOT 2
- Node Tree Element potential child: Attr ? HOT 5
- Proposal: AbortSignal.none() HOT 4
- I can't find where inserting DocumentType nodes into Element nodes is disallowed HOT 1
- Proposal AbortSignal.prototype.filter(compare) HOT 4
- `mutationObserver.disconnect({ flush: true })` HOT 1
- Proposal: SelectorObserver HOT 2
- Proposal: elementsFromRect() HOT 2
- `MutationObserver` flag to observe mutations in (open) shadow trees to facilitate polyfills of HTML syntax HOT 9
- Request for mechanism to determine if children changed steps are called as a result of script or parser HOT 2
- Add a method like .addTeardown to AbortSignal
- Closed Shadow DOM blocks accessibility testing HOT 1
- Should post-connected steps be able to run multiple times during insertion?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dom.