-
Notifications
You must be signed in to change notification settings - Fork 297
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Strange behavior with insertBefore
vs appendChild
and transitions
#880
Comments
Maybe @emilio or @tabatkins knows why this happens. This should probably be filed over at https://github.com/w3c/csswg-drafts/issues/new though. |
@annevk Filed: w3c/csswg-drafts#5334 |
Thanks to the explanation there I recalled whatwg/html#5484. @josepharhar here's a concrete example as to what a move primitive might improve. |
If it helps, this is in the context of FLIP animations for list move transitions. |
Question: would it be web-compatible to do this, or would this be too breaking? Add the following operation to trees:
This is just spec jargon for "don't do things that happen when you add or remove elements". In implementations, this would still necessitate removing and then re-adding, but only as an implementation detail. Amend the adopt algorithm to this:
Amend step 4 of Replace steps 7.2-7.3 of insert with the following:
Amend step 11 of replace to be this:
Amend replace all to move children rather than removing them if their parents are parent (as defined in the algorithm), and update its callees like
To assess risk, you would want to check for elements that 1. would be moved to any position other than the end according to this change, 2. have active transitions, animations, or mutation observers, and 3. for transitions, didn't have their styles synchronously calculated (for |
Thanks for writing this up! It sounds like moving elements around within the same parent without clobbering state could be a huge win! I'm interested to hear what the react and preact maintainers say about it in the whatwg/html thread. |
Npc list?
Get Outlook for Android<https://aka.ms/ghei36>
…________________________________
From: Joey Arhar <[email protected]>
Sent: Tuesday, August 11, 2020 6:58:25 AM
To: whatwg/dom <[email protected]>
Cc: Subscribed <[email protected]>
Subject: Re: [whatwg/dom] Strange behavior with `insertBefore` vs `appendChild` and transitions (#880)
Thanks for writing this up! It sounds like moving elements around within the same parent without clobbering state could be a huge win! I'm interested to hear what the react and preact maintainers say about it in the whatwg/html thread.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub<#880 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AO6Z7OQYPWPZCNCNLC3YKQLSAC6WDANCNFSM4PB7QJXQ>.
|
@josepharhar Thanks! Of course, I just maintain Mithril - React and Preact of course have different concerns as they're implemented slightly differently, but I suspect it should work for them if I were to take an educated guess. (Preact is a lot like us but with fewer internal optimizations based on a cursory look, and React uses linked lists for everything IIUC.) |
@sebmarkbage @marvinhagemeister @developit |
@josepharhar Sorry for being late to answer! The improvements outlined here would help us tremendously for Preact 👍 Same goes for the other issue. |
@isiahmeadows I don't think that would be web-compatible as the side effects of insertion and removal would not be triggered. We'd also want different mutation records for moving vs insertion/removal. |
When using
insertBefore
with transitions and the FLIP technique, I get very strange results across browsers.appendChild
insertBefore
The only difference is the way the DOM nodes are rearranged, which is what confuses me about this.
Code for each
insertBefore
:appendChild
:I've reproduced this behavior explained above on each of the following platforms:
Relevant framework bugs I've filed, before I narrowed it down further to this:
I suspect it's a bug in all three of those listed browsers, but I'm filing an issue here in case it's actually a spec issue or if a spec note is necessary for this.
The text was updated successfully, but these errors were encountered: