f# - FunScript querySelector null result -


i want use document.queryselector method html node. in js can receive null result. in f# result type element , it's neither nullable nor optional , it's not clear how check null. how can handle situation when queryselector doesn't match dom node?

yes, it's true f# code assumes element not nullable. can trick compiler think otherwise in several ways. easiest 1 box value this:

let el = globals.document.queryselector(".myclass") if (box el) = null dosomething() else dosomethingelse()` 

box ignored when generating js code, there's no performance penalty in doing this.


Comments

Popular posts from this blog

apache - PHP Soap issue while content length is larger -

asynchronous - Python asyncio task got bad yield -

javascript - Complete OpenIDConnect auth when requesting via Ajax -