Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Testing the patch function in purescript-virtual-dom
module Main where
import Prelude
import Data.DOM.Simple.Document
import Data.DOM.Simple.Element
import Data.DOM.Simple.Window
import qualified VirtualDOM as VD
import qualified VirtualDOM.VTree as VT
foreign import isoTS :: DOM.Node -> Data.DOM.Simple.Types.HTMLElement
foreign import isoST :: Data.DOM.Simple.Types.HTMLElement -> DOM.Node
main = do
let x = VT.vtext "Hello!"
let node = VD.createElement x
doc <- document globalWindow
bod <- body doc
appendChild bod (isoTS node)
let y = VT.vtext "Goodbye!"
let d = VD.diff x y
VD.patch d node
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment