I think I might be missing a key function in the purescript-dom
module to convert from a Node to a specific element type. For instance if I have a Event
, I can use DOM.Events.Events.target to get the Node, but it seems like the only way to get a specific element is with unsafeCoerce
, e.g.
import DOM.Event.Event (target)
import DOM.HTML.HTMLInputElement (value)
eval (InputChange event next) = do
-- Get the value of the HTMLInputElement assuming it is one
v <- H.liftEff $ value (unsafeCoerce $ target event)
H.liftEff $ log "Input field change"
H.liftEff $ log v
pure next
Is there a better way to go from a Node to an element type?