Permalink
Browse files

Less hacky way of determining if a symbol refers to js/this

  • Loading branch information...
1 parent b34f381 commit e434da6c6c58707a668b188b63e6da1ded37ae75 @fogus fogus committed Sep 2, 2011
Showing with 3 additions and 5 deletions.
  1. +3 −5 src/clj/cljs/compiler.clj
@@ -16,8 +16,6 @@
(declare resolve-var)
(require 'cljs.core)
-(def js-this 'this)
-
(def js-reserved
#{"abstract" "boolean" "break" "byte" "case"
"catch" "char" "class" "const" "continue"
@@ -39,7 +37,7 @@
(def ^:dynamic *cljs-warn-on-undeclared* false)
(defn munge [s]
- (if (identical? s js-this)
+ (if (:js-this (meta s))
s
(let [ss (str s)
ms (if (.contains ss "]")
@@ -77,8 +75,8 @@
(let [parts (string/split (name sym) #"\.")
first (first parts)
step (fn [part] (str "['" part "']"))]
- (if (= (symbol first) js-this)
- js-this
+ (if (= "this" first)
+ (with-meta (symbol first) {:js-this true})
(apply str first (map step (rest parts))))))
(defn resolve-existing-var [env sym]

0 comments on commit e434da6

Please sign in to comment.