Misc cleanup

This commit is contained in:
Dan Holmsand 2014-12-08 13:37:25 +01:00
parent 59b2e6d6ee
commit 197aca78d4
4 changed files with 10 additions and 37 deletions

View File

@ -59,6 +59,7 @@ trigger-build:
push-gh-pages: build-gh-pages push-gh-pages: build-gh-pages
git push origin gh-pages:gh-pages git push origin gh-pages:gh-pages
# build site into a gh-pages branch
build-gh-pages: gen-site gh-pages-add build-gh-pages: gen-site gh-pages-add
gen-site: clean gen-site: clean

View File

@ -1,4 +1,3 @@
(ns reagent.impl.component (ns reagent.impl.component
(:require [reagent.impl.util :as util] (:require [reagent.impl.util :as util]
[reagent.impl.batching :as batch] [reagent.impl.batching :as batch]
@ -38,7 +37,7 @@
(defn do-render [c] (defn do-render [c]
(binding [*current-component* c] (binding [*current-component* c]
(let [f (.' c :cljsRender) (let [f (.' c :cljsRender)
_ (assert (util/clj-ifn? f)) _ (assert (ifn? f))
p (.' c :props) p (.' c :props)
res (if (nil? (.' c :componentFunction)) res (if (nil? (.' c :componentFunction))
(f c) (f c)
@ -169,7 +168,7 @@
(defn wrap-funs [fun-map] (defn wrap-funs [fun-map]
(let [render-fun (or (:componentFunction fun-map) (let [render-fun (or (:componentFunction fun-map)
(:render fun-map)) (:render fun-map))
_ (assert (util/clj-ifn? render-fun) _ (assert (ifn? render-fun)
(str "Render must be a function, not " (str "Render must be a function, not "
(pr-str render-fun))) (pr-str render-fun)))
name (str (or (:displayName fun-map) name (str (or (:displayName fun-map)

View File

@ -1,4 +1,3 @@
(ns reagent.impl.template (ns reagent.impl.template
(:require [clojure.string :as string] (:require [clojure.string :as string]
[reagent.impl.util :as util :refer [is-client]] [reagent.impl.util :as util :refer [is-client]]
@ -28,14 +27,12 @@
(defn valid-tag? [x] (defn valid-tag? [x]
(or (hiccup-tag? x) (or (hiccup-tag? x)
(util/clj-ifn? x))) (ifn? x)))
(defn to-js-val [v] (defn to-js-val [v]
(cond (cond
(string? v) v (or (string? v) (number? v)) v
(number? v) v (implements? INamed v) (name v)
(keyword? v) (name v)
(symbol? v) (str v)
(coll? v) (clj->js v) (coll? v) (clj->js v)
(ifn? v) (fn [& args] (apply v args)) (ifn? v) (fn [& args] (apply v args))
:else v)) :else v))
@ -48,7 +45,6 @@
;;; Props conversion ;;; Props conversion
(def cached-prop-name (util/memoize-1 undash-prop-name)) (def cached-prop-name (util/memoize-1 undash-prop-name))
(def cached-style-name (util/memoize-1 util/dash-to-camel))
(defn convert-prop-value [x] (defn convert-prop-value [x]
(cond (string? x) x (cond (string? x) x
@ -120,8 +116,8 @@
(.! this :cljsInputValue nil))) (.! this :cljsInputValue nil)))
(defn input-component? [x] (defn input-component? [x]
(or (= x "input") (or (identical? x "input")
(= x "textarea"))) (identical? x "textarea")))
(def reagent-input-class nil) (def reagent-input-class nil)

View File

@ -76,13 +76,6 @@
IHash IHash
(-hash [_] (hash [f args]))) (-hash [_] (hash [f args])))
; patch for CLJS-777; Can be replaced with clojure.core/ifn? after updating
; ClojureScript to a version that includes the fix:
; https://github.com/clojure/clojurescript/commit/525154f2a4874cf3b88ac3d5755794de425a94cb
(defn clj-ifn? [x]
(or (ifn? x)
(satisfies? IMultiFn x)))
(defn- merge-class [p1 p2] (defn- merge-class [p1 p2]
(let [class (when-let [c1 (:class p1)] (let [class (when-let [c1 (:class p1)]
(when-let [c2 (:class p2)] (when-let [c2 (:class p2)]
@ -109,19 +102,6 @@
(declare ^:dynamic *always-update*) (declare ^:dynamic *always-update*)
(def doc-node-type 9)
(def react-id-name "data-reactid")
(defn get-react-node [cont]
(when (some? cont)
(if (== doc-node-type (.' cont :nodeType))
(.' cont :documentElement)
(.' cont :firstChild))))
(defn get-root-id [cont]
(some-> (get-react-node cont)
(.' getAttribute react-id-name)))
(defonce roots (atom {})) (defonce roots (atom {}))
(defn clear-container [node] (defn clear-container [node]
@ -130,10 +110,8 @@
(try (try
(.' js/React unmountComponentAtNode node) (.' js/React unmountComponentAtNode node)
(catch js/Object e (catch js/Object e
(log e))) (do (log "Error unmounting:")
(when-let [n (get-react-node node)] (log e)))))
(.' n removeAttribute react-id-name)
(.! n :innerHTML "")))
(defn render-component [comp container callback force-update] (defn render-component [comp container callback force-update]
(try (try
@ -207,4 +185,3 @@
(Wrapper. value (Wrapper. value
(partial-ifn. callback-fn args nil) (partial-ifn. callback-fn args nil)
false)) false))