mirror of https://github.com/status-im/reagent.git
Misc cleanup
This commit is contained in:
parent
59b2e6d6ee
commit
197aca78d4
1
Makefile
1
Makefile
|
@ -59,6 +59,7 @@ trigger-build:
|
|||
push-gh-pages: build-gh-pages
|
||||
git push origin gh-pages:gh-pages
|
||||
|
||||
# build site into a gh-pages branch
|
||||
build-gh-pages: gen-site gh-pages-add
|
||||
|
||||
gen-site: clean
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
(ns reagent.impl.component
|
||||
(:require [reagent.impl.util :as util]
|
||||
[reagent.impl.batching :as batch]
|
||||
|
@ -38,7 +37,7 @@
|
|||
(defn do-render [c]
|
||||
(binding [*current-component* c]
|
||||
(let [f (.' c :cljsRender)
|
||||
_ (assert (util/clj-ifn? f))
|
||||
_ (assert (ifn? f))
|
||||
p (.' c :props)
|
||||
res (if (nil? (.' c :componentFunction))
|
||||
(f c)
|
||||
|
@ -169,7 +168,7 @@
|
|||
(defn wrap-funs [fun-map]
|
||||
(let [render-fun (or (:componentFunction fun-map)
|
||||
(:render fun-map))
|
||||
_ (assert (util/clj-ifn? render-fun)
|
||||
_ (assert (ifn? render-fun)
|
||||
(str "Render must be a function, not "
|
||||
(pr-str render-fun)))
|
||||
name (str (or (:displayName fun-map)
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
(ns reagent.impl.template
|
||||
(:require [clojure.string :as string]
|
||||
[reagent.impl.util :as util :refer [is-client]]
|
||||
|
@ -28,14 +27,12 @@
|
|||
|
||||
(defn valid-tag? [x]
|
||||
(or (hiccup-tag? x)
|
||||
(util/clj-ifn? x)))
|
||||
(ifn? x)))
|
||||
|
||||
(defn to-js-val [v]
|
||||
(cond
|
||||
(string? v) v
|
||||
(number? v) v
|
||||
(keyword? v) (name v)
|
||||
(symbol? v) (str v)
|
||||
(or (string? v) (number? v)) v
|
||||
(implements? INamed v) (name v)
|
||||
(coll? v) (clj->js v)
|
||||
(ifn? v) (fn [& args] (apply v args))
|
||||
:else v))
|
||||
|
@ -48,7 +45,6 @@
|
|||
;;; Props conversion
|
||||
|
||||
(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]
|
||||
(cond (string? x) x
|
||||
|
@ -120,8 +116,8 @@
|
|||
(.! this :cljsInputValue nil)))
|
||||
|
||||
(defn input-component? [x]
|
||||
(or (= x "input")
|
||||
(= x "textarea")))
|
||||
(or (identical? x "input")
|
||||
(identical? x "textarea")))
|
||||
|
||||
(def reagent-input-class nil)
|
||||
|
||||
|
|
|
@ -76,13 +76,6 @@
|
|||
IHash
|
||||
(-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]
|
||||
(let [class (when-let [c1 (:class p1)]
|
||||
(when-let [c2 (:class p2)]
|
||||
|
@ -109,19 +102,6 @@
|
|||
|
||||
(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 {}))
|
||||
|
||||
(defn clear-container [node]
|
||||
|
@ -130,10 +110,8 @@
|
|||
(try
|
||||
(.' js/React unmountComponentAtNode node)
|
||||
(catch js/Object e
|
||||
(log e)))
|
||||
(when-let [n (get-react-node node)]
|
||||
(.' n removeAttribute react-id-name)
|
||||
(.! n :innerHTML "")))
|
||||
(do (log "Error unmounting:")
|
||||
(log e)))))
|
||||
|
||||
(defn render-component [comp container callback force-update]
|
||||
(try
|
||||
|
@ -207,4 +185,3 @@
|
|||
(Wrapper. value
|
||||
(partial-ifn. callback-fn args nil)
|
||||
false))
|
||||
|
||||
|
|
Loading…
Reference in New Issue