I’m new to Clojurescript but I have been playing around with Clojure for a while now. Recently I came across a Conway Game of Life example in the Clojure Programming book and I thought it would be fun to code it in Clojurescript and re-frame.
I managed to create one version which is working in dev mode. But when I compile it in production mode and run it, part of it stopped working (it is supposed to highlight the cell that the mouse pointer is on and to toggle the cell on mouse click).
Using pretty print and pseudo name compiler options, the error on the browser console is:
Uncaught TypeError: $cell_size$jscomp$1$$.$createSVGPoint$ is not a function at app.js:11480
I’m calling this function on a SVG element like this:
(defn- svg-pos [client-pos svg-elem] (let [[x y] client-pos svg-point (.createSVGPoint svg-elem) matrix (-> svg-elem .getScreenCTM .inverse)] (set! (.-x svg-point) x) (set! (.-y svg-point) y) (let [gpt (.matrixTransform svg-point matrix)] [(int (.-x gpt)) (int (.-y gpt))])))
When I switched to simple optimisation, I don’t get the error.
Here’s the demo using simple optimization.
Is there something that I need to do to use advance compilation?