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

php - Wordpress: Link a post to posts of another category manually -

delphi xe7 upload/download dropbox file using the rest client and show progress -

java - Get more than One value and display it -