elm / virtual-dom

The foundation of HTML and SVG in Elm.
https://package.elm-lang.org/packages/elm/virtual-dom/latest
BSD 3-Clause "New" or "Revised" License
209 stars 80 forks source link

Lazy top-level view crashes when patches happen after the rootnode changed #110

Open zwilias opened 7 years ago

zwilias commented 7 years ago

SSCCE: https://ellie-app.com/3Vd6CqrthVYa1/2

On init, the rootnode is changed. After that, clicking the click me div results in applying a patch within that changed rootnode. Stepping through that process with a debugger reveals the rootnode is still an h4 at that point. The p-thunk patch can't seem to replace the rootnode.

p-thunk's domNode property is undefined so the result of applyPatch cannot replace the actual node. This then later on results in patches being applied to the wrong DOM node, and stuff blowing up.

process-bot commented 7 years ago

Thanks for the issue! 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.

antew commented 6 years ago

It seems if you wrap it in another node that it fixes the crash https://ellie-app.com/cjSYRKqh5a1/0