From 197aca78d443f4b6b623bf88f570232bb31cd5fa Mon Sep 17 00:00:00 2001 From: Dan Holmsand Date: Mon, 8 Dec 2014 13:37:25 +0100 Subject: [PATCH] Misc cleanup --- Makefile | 1 + src/reagent/impl/component.cljs | 5 ++--- src/reagent/impl/template.cljs | 14 +++++--------- src/reagent/impl/util.cljs | 27 ++------------------------- 4 files changed, 10 insertions(+), 37 deletions(-) diff --git a/Makefile b/Makefile index 6d21c4a..5cea025 100644 --- a/Makefile +++ b/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 diff --git a/src/reagent/impl/component.cljs b/src/reagent/impl/component.cljs index fb08e0f..32efe6c 100644 --- a/src/reagent/impl/component.cljs +++ b/src/reagent/impl/component.cljs @@ -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) diff --git a/src/reagent/impl/template.cljs b/src/reagent/impl/template.cljs index 4c41dd0..9861dee 100644 --- a/src/reagent/impl/template.cljs +++ b/src/reagent/impl/template.cljs @@ -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) diff --git a/src/reagent/impl/util.cljs b/src/reagent/impl/util.cljs index 7939f21..21eb6b9 100644 --- a/src/reagent/impl/util.cljs +++ b/src/reagent/impl/util.cljs @@ -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)) -