Skip to content

Instantly share code, notes, and snippets.

@srikumarks
Created May 3, 2015 03:51
Show Gist options
  • Save srikumarks/607a073f1d3da8bc1570 to your computer and use it in GitHub Desktop.
Save srikumarks/607a073f1d3da8bc1570 to your computer and use it in GitHub Desktop.
Virtual DOM diffing failure when mixing Graphics.Element and Html.
module VirtualDomFailure where
import Window
import Time
import Html exposing (..)
import Html.Attributes exposing (..)
import Graphics.Element exposing (..)
import Signal exposing (..)
googleLogo = "https://www.google.co.in/images/srpr/logo11w.png"
-- Element. Does DOM diffing correctly
comp1 t w h = flow down [
image 538 190 googleLogo
]
-- Html. Does DOM diffing correctly.
comp2 t w h = div [] [
text "hello world!",
img [src googleLogo] []
]
-- Mixing Element and Html. Recreates DOM elements repeatedly.
comp3 t w h = div [] [
fromElement <| comp1 t w h,
text "hello world!"
]
integrate = Signal.foldp (+) 0.0
main = comp1 <~ (Time.fps 60 |> integrate) ~ Window.width ~ Window.height
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment