Repository navigation
Fix dekey reading Elm's tuple field from keyed children - #106
Merged
Merged
Conversation
_VirtualDom_dekey still read keyedKids[i].b, the field of Elm's
(key, node) tuples. Gren's keyed children are { key, node } records,
which every other kernel site reads through __$node. On the diff path
where an old plain node meets a new keyed node at the same index,
dekey therefore produced a node whose children were all undefined,
and the following redraw crashed with "Cannot read properties of
undefined (reading '$')", after which the real DOM and the virtual
one never agreed again.
Verified against a minimal reproduction — a keyed node last in a
child list whose shape changes across an update: the untouched
kernel crashes on the first update, this change alone stops it, and
reverting brings the crash back.
Member
|
The fix looks good, but I haven't had the time to run the minimal repro case to verify. Will try to make time in the coming days. |
|
For what it's worth, I ran into the same problem last night in a little web app I'm writing. My HTML body has a Just/Nothing The first render (the Nothing case) was fine. When I clicked the page and Instrumenting the compiled output at the point of the
I patched my compiled javascript with the |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes the crash discussed on Discord (keyed node in a child list whose
shape changes across an update).
_VirtualDom_dekeystill readkeyedKids[i].b— the field of Elm's(key, node)tuples. Gren's keyed children are{ key, node }records,which every other kernel site reads through
__$node(_VirtualDom_render,the keyed constructor's descendants count). On the diff path where an old
plain node meets a new keyed node at the same index, dekey therefore
produced a node whose children were all
undefined; the following redrawcrashed with
Cannot read properties of undefined (reading '$'), and fromthen on every render threw
removeChildtype errors as the real DOM andthe virtual one drifted apart.
Minimal reproduction (click once):
Verified by patching a package-cache copy of the kernel: the untouched
6.0.2 crashes on the first update, this change alone stops it, and
reverting brings the crash back.
gren makecompiles all 24 modules withthe change.