Do a little cleanup in template.cljs

This commit is contained in:
Dan Holmsand 2015-09-27 11:14:32 +02:00
parent 83b21167ea
commit 7cd2d7d860
1 changed files with 10 additions and 10 deletions

View File

@ -18,15 +18,15 @@
;;; Common utilities
(defn named? [x]
(defn ^boolean named? [x]
(or (keyword? x)
(symbol? x)))
(defn hiccup-tag? [x]
(defn ^boolean hiccup-tag? [x]
(or (named? x)
(string? x)))
(defn valid-tag? [x]
(defn ^boolean valid-tag? [x]
(or (hiccup-tag? x)
(ifn? x)
(instance? NativeWrapper x)))
@ -39,7 +39,7 @@
:charset "charSet"})
(defn obj-get [o k]
(when (.hasOwnProperty o k)
(when (true? (.hasOwnProperty o k))
(aget o k)))
(defn cached-prop-name [k]
@ -95,7 +95,7 @@
;; See: https://html.spec.whatwg.org/multipage/forms.html#do-not-apply
(def these-inputs-have-selection-api #{"text" "textarea" "password" "search" "tel" "url"})
(defn has-selection-api?
(defn ^boolean has-selection-api?
[input-type]
(contains? these-inputs-have-selection-api input-type))
@ -160,7 +160,7 @@
(.! :onChange #(input-handle-change this on-change %))))
(.! this :cljsInputValue nil)))
(defn input-component? [x]
(defn ^boolean input-component? [x]
(or (identical? x "input")
(identical? x "textarea")))
@ -188,13 +188,13 @@
(defn parse-tag [hiccup-tag]
(let [[tag id class] (->> hiccup-tag name (re-matches re-tag) next)
class' (when class
(string/replace class #"\." " "))]
class (when-not (nil? class)
(string/replace class #"\." " "))]
(assert tag (str "Invalid tag: '" hiccup-tag "'"
(comp/comp-name)))
#js{:name tag
:id id
:className class'}))
:className class}))
(defn fn-to-class [f]
(assert (ifn? f) (str "Expected a function, not " (pr-str f)))
@ -320,7 +320,7 @@
(expand-seq-dev x ctx)
(ratom/capture-derefed #(expand-seq-dev x ctx)
ctx))]
(when (ratom/captured ctx)
(when-not (nil? (ratom/captured ctx))
(warn "Reactive deref not supported in lazy seq, "
"it should be wrapped in doall"
(comp/comp-name) ". Value:\n" (pr-str x)))