Changing boolean properties?

17 views
Skip to first unread message

hall...@chalmers.se

unread,
Dec 9, 2016, 9:43:37 PM12/9/16
to haste-compiler
Hi,

How do you changed the "checked" property of a an <input type="checkbox"> with Haste? In JavaScript,t his would be

    cb.checked=false
    cb.checked=true

I tried

    setProp cb "checked" "true"
    setProp cb "checked" "true"

but this does not work, presumably because it translates to

    cb.checked="false"
    cb.checked="true"

and converting any non-empty string is interpreted as true when converted to a boolean in JavaScript...

--
Thomas H

Anton Ekblad

unread,
Jan 17, 2017, 8:17:00 AM1/17/17
to haste-compiler
Hi,
Haste.DOM currently doesn't provide a way to do this, which is a bit dumb. The upcoming 0.6 release will have two new functions, unsetProp and unsetAttr, to fix this. In the meantime, the problem can be worked around using the FFI:

unsetProp :: Elem -> JSString -> IO ()
unsetProp = ffi "(function(e,p){delete e[p];})"

Barring any major disruptions, 0.6 will be out in a few days however.

/Anton

--
You received this message because you are subscribed to the Google Groups "haste-compiler" group.
To unsubscribe from this group and stop receiving emails from it, send an email to haste-compiler+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages