From fed3ecb430514d08e8f841ee57d5b981cf6c1258 Mon Sep 17 00:00:00 2001 From: Wes Brown Date: Sat, 26 Apr 2014 11:50:04 -0400 Subject: [PATCH] Implement CLJS-495 on the clojure version of the compiler by applying https://github.com/clojure/clojurescript/commit/3ee148acac436dd489396fc6783ba72bbd7ff79f -- on the cljs version, it's a defn that calls goog/typeOf. --- src/clj/cljs/core.clj | 3 +++ src/cljs/cljs/core.cljs | 4 ++++ web/vendor/jq-console | 2 +- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/clj/cljs/core.clj b/src/clj/cljs/core.clj index c0d943814..61c0c530d 100644 --- a/src/clj/cljs/core.clj +++ b/src/clj/cljs/core.clj @@ -202,6 +202,9 @@ (defmacro false? [x] (bool-expr (list 'js* "~{} === false" x))) +(defmacro exists? [x] + (bool-expr (list 'js* "typeof ~{} !== 'undefined'" x))) + (defmacro undefined? [x] (bool-expr (list 'js* "(void 0 === ~{})" x))) diff --git a/src/cljs/cljs/core.cljs b/src/cljs/cljs/core.cljs index 7e6ffd648..3a7fe099d 100644 --- a/src/cljs/cljs/core.cljs +++ b/src/cljs/cljs/core.cljs @@ -1004,6 +1004,10 @@ reduces them without incurring seq initialization" "Returns true if x is the value true, false otherwise." [x] (cljs.core/true? x)) +(defn ^boolean exists? + "Return true if object exists, false otherwise." + [x] (not= "undefined" (goog/typeOf x))) + (defn ^boolean undefined? [x] (cljs.core/undefined? x)) diff --git a/web/vendor/jq-console b/web/vendor/jq-console index 19e247d6f..309fa621f 160000 --- a/web/vendor/jq-console +++ b/web/vendor/jq-console @@ -1 +1 @@ -Subproject commit 19e247d6f546c64596073faed3ff7b0747f5d6b3 +Subproject commit 309fa621f107bccced6b461c0c703fbc64b24167