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 965
965
" Return true if argument exists, analogous to usage of typeof operator
966
966
in JavaScript."
967
967
[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))))
971
977
972
978
(core/defmacro undefined?
973
979
" Return true if argument is identical to the JavaScript undefined value."
Original file line number Diff line number Diff line change 727
727
(is (false ? (exists? js/jQuery)))
728
728
(is (exists? exists?-test-val))))
729
729
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
+
730
736
(deftest test-518
731
737
(is (nil? (:test " test" ))))
732
738
You can’t perform that action at this time.
0 commit comments