In clojurescript 1.9.89 and Chrome 50.0.2661.102, I can create a log statement like:
(js/console.log "works")
But I can't create one like:
(def brokenlog js/console.log)
(brokenlog "but not here")
--> #object[TypeError TypeError: Illegal invocation]
When I try to compare these approaches by printing the value of my own brokenlog
function, it looks just like the "real one" -- that is, both brokenlog
and js/console.log
evaluate for me as:
#object[log "function log() { [native code] }"]
Similarly, I see this behavior with:
cljs.user=> (js/document.querySelector "body")
#object[HTMLBodyElement [object HTMLBodyElement]]
cljs.user=> (def l js/document.querySelector)
#'cljs.user/l
cljs.user=> (l "body")
#object[TypeError TypeError: Illegal invocation]
nil
Upgrading to Chrome 52 fixes the console.log
behavior, but not the document.querySelector
behavior.
So I have two questions:
1. What am I missing
2. Where are the official docs I should be reading that would explain it?
Thanks!