File tree Expand file tree Collapse file tree 2 files changed +15
-3
lines changed
Expand file tree Collapse file tree 2 files changed +15
-3
lines changed Original file line number Diff line number Diff line change 965965 " Return true if argument exists, analogous to usage of typeof operator
966966 in JavaScript."
967967 [x]
968- (bool-expr
969- (core/list 'js* " typeof ~{} !== 'undefined'"
970- (vary-meta x assoc :cljs.analyzer/no-resolve true ))))
968+ (let [x (:name (cljs.analyzer/resolve-var &env x))
969+ segs (string/split (core/str (string/replace x #"\/ " " ." )) #"\. " )
970+ n (count segs)
971+ syms (map
972+ #(vary-meta (symbol " js" (string/join " ." %))
973+ assoc :cljs.analyzer/no-resolve true )
974+ (reverse (take n (iterate butlast segs))))
975+ js (string/join " && " (repeat n " (typeof ~{} !== 'undefined')" ))]
976+ (bool-expr (concat (core/list 'js* js) syms))))
971977
972978(core/defmacro undefined?
973979 " Return true if argument is identical to the JavaScript undefined value."
Original file line number Diff line number Diff line change 727727 (is (false ? (exists? js/jQuery)))
728728 (is (exists? exists?-test-val))))
729729
730+ (deftest test-2764
731+ (testing " Testing CLJS-2764, exists? on multi-segment symbols"
732+ (is (false ? (exists? this.ns.does.not.exist)))
733+ (is (true ? (exists? cljs.core.first)))
734+ (is (true ? (exists? cljs.core/first)))))
735+
730736(deftest test-518
731737 (is (nil? (:test " test" ))))
732738
You can’t perform that action at this time.
0 commit comments