Permalink
Browse files

fix eventtype issue in advanced compilation. Closes #14.

Signed-off-by: Chris Granger <ibdknox@gmail.com>
  • Loading branch information...
1 parent dd08f21 commit 5ed0823db3d4ba85412f4d12c7c266c258fab13f @ibdknox committed Dec 22, 2011
Showing with 14 additions and 9 deletions.
  1. +5 −1 src/noir/pinot/remotes.clj
  2. +7 −6 src/pinot/dom.cljs
  3. +2 −2 src/pinot/events.cljs
@@ -9,6 +9,10 @@
(defn add-remote [remote func]
(swap! remotes assoc remote func))
+(defn safe-read [s]
+ (binding [*read-eval* false]
+ (read-string s)))
+
(defmacro defremote [remote params & body]
`(do
(defn ~remote ~params ~@body)
@@ -25,7 +29,7 @@
(defn wrap-remotes [handler]
(fn [{:keys [uri body] :as req}]
(if (re-seq remote-regex uri)
- (let [{:keys [remote params]} (read-string (slurp body))
+ (let [{:keys [remote params]} (safe-read (slurp body))
remote (keyword remote)]
(call-remote remote params))
(handler req))))
View
@@ -33,12 +33,13 @@
(defn attr
([elem attrs]
- (if-not (map? attrs)
- (. elem (getAttribute (name attrs)))
- (do
- (doseq [[k v] attrs]
- (attr elem k v))
- elem)))
+ (when elem
+ (if-not (map? attrs)
+ (. elem (getAttribute (name attrs)))
+ (do
+ (doseq [[k v] attrs]
+ (attr elem k v))
+ elem))))
([elem k v]
(doseq [el (pclj/->coll elem)]
(. el (setAttribute (name k) v)))
View
@@ -39,9 +39,9 @@
(func match e)
true))))
+
(defn on [elem event func]
- (let [ev-name (string/upper-case (name event))
- event (aget events/EventType ev-name)
+ (let [event (string/lower-case (name event))
@davesann

davesann Dec 27, 2011

This fixes the issue with advanced compilation for issue #14.
But it does lose the small number of portability benefits brought by the EventType lookup.
I have a cljs port of EventType as a keyword indexed map, if you would like me to provide it.
D

body-elem (get-body)]
(doseq [el (pclj/->coll elem)]
(let [parsed (->target el)]

0 comments on commit 5ed0823

Please sign in to comment.