-
Notifications
You must be signed in to change notification settings - Fork 80
Description
During last weeks I've been working on a app that initialize a map (leaflet) in a dom element created by a view function in elm. This has been working great. I wanted for elm to manage root dom element of the page and not to be embedded in a particular dom.
So far so good.
But after tidying things a little bit and using Html.App.map
in the view function, the virtual dom algorithm is unable to reuse the dom.
I've reduced as much as possible the sample in https://gist.github.com/bcardiff/d59fa6b70d4aa486534b485049c5be8e so it might look a bit cryptic . A #my-div
is mutated from JS, but there is always a #my-div
in the same location across life cycle of the application.
With the gist code, when rendering the view using Html.App.map
the #my-div
is recreated from scratch, loosing the previous mutation: http://g.recordit.co/GaF2HCbynG.gif
Oddly, if instead of using Html.App.map
the view is built directly with a wrapping a -> msg
function the problem goes away. That is, using https://gist.github.com/bcardiff/d59fa6b70d4aa486534b485049c5be8e#gistcomment-1887851 I got the expected behavior: http://g.recordit.co/Mflh3NmM6y.gif
Am I right in considering this a bug or is off the limits of the diff algorithm of virtual dom?
virutal-dom: 1.1.1