Fix wrong DOM order on suspend inside Fragment#2107
Conversation
sventschui
left a comment
There was a problem hiding this comment.
As you probably already saw I am super busy the past weeks and didn't spend that much time on preact. I nevertheless wanted to drop some comments here as I find this PR super interesting.
The cave-at with the suspensions/Promise de-duplication should be looked at and I'm super happy to chat here or on slack if you have any questions. Also I try to dig up my de-duplication work and see where this went if I can find some spare minutes.
Anyways thank you for having a look at improving the current implementation :)
|
|
||
| /** @jsx createElement */ | ||
|
|
||
| async function waitResolved(suspense) { |
There was a problem hiding this comment.
In another branch I'm rewriting tests that rely on internals. If you are interested, I rewrote these tests to no longer rely on _suspensions if you'd like to pull that change in :)
There was a problem hiding this comment.
Sweet! Sorry that I didn't react to this in time. If this PR caused merge conflicts to your branch I can create a patch to resolve them.
|
Updated the implementation. Now DOM is not modified manually at all. Instead the suspended component is removed/detached/lifted from the rendered tree to keep the component's state intact, and added back to the rendered tree when the suspension gets resolved. The This brings the compat.js.gz bundle size further down by 7 bytes (now 2655 B vs. the 2700 B in the master branch, 45 B reduction in total). |
|
Merging, coveralls is acting up strangely again... |
|
maybe coveralls is right. There are some missed branches in the suspense impl. Might be worth looking at these. I might find some time to do so later today |
|
Note, if you click on the "coverage" badge you can see exactly which lines and branches aren't covered |
|
There were no coverage changes related to any files in this PR. The one were coverage went down was the entry file of |
|
One problem: Anything relying on Anything traversing props.children will probably break. Unless thats an anti pattern for libraries that I am not aware of |
|
@prateekbh |
|
You're right I mistakenly added a ghost space in my tests and thought it came because of this |
|
All good 👍👍👍 |
This pull request fixes issue #2106 and refactors the Suspense implementation for smaller code size.
_detachOnNextRenderflag and force a new render withsetState.The changes in this PR bring down the compat.js.gz bundle size by 38 bytes (from 2700 B to 2662 B).
Fixes #2106.