Closed mlandauer closed 3 years ago
Thanks for the pull request! Make sure it satisfies this checklist. My human colleagues will appreciate it!
Here is what to expect next, and if anyone wants to comment, keep these things in mind.
I wondered if this issue persists in Elm 0.19, so I forked the test handover and upgraded. https://github.com/Pilatch/elm-test-handover/tree/reproduce-issue-in-elm-0.19
On my MacBook Pro, which is probably not a great test bed, I cannot see the white flash in 0.19.
Since this has never (as far as I can tell) been looked at by any maintainer
@mlandauer They should eventually come around to looking at it in a "batch". I don't think it needs to be closed.
This improves the visual smoothness of hand-over between static rendered HTML and dynamic HTML that is produced by Elm.
Currently, if we have a large amount of statically generated HTML which is replaced by a large amount of HTML rendered by Elm, on running
App.Main.embed
there will be noticeable period between the old static content getting removed and the new content being added. Depending on the styling this can result in the appearance of a "white flash".This commit does the absolute minimum to bring the removal and addition closer together so that the white flash is minimised. There are further optimisations that could be done. For instance, we could in the case of a single child use
node.replaceChild
instead ofnode.removeChild
followed bynode.appendChild
.At https://github.com/mlandauer/elm-test-handover there's a very simple elm app which demonstrates the issue. This is what happens now:
The red box is static HTML content which is then replaced by the nearly identical green box rendered by Elm. There is a short period between where there is nothing rendered (the white flash).
Here you can see the effect of this patch.
The white flash between the red and green box has gone.