diff --git a/Makefile b/Makefile index 81369a8..6b4f8bf 100644 --- a/Makefile +++ b/Makefile @@ -9,7 +9,7 @@ PROF = dev,test CLJSBUILD = client CLJSDIRS = src test -VERSION = 0.0.1-SNAPSHOT +VERSION = 0.0.2-SNAPSHOT all: buildrun diff --git a/examples/simple/project.clj b/examples/simple/project.clj index 7e1af4b..60e6f22 100644 --- a/examples/simple/project.clj +++ b/examples/simple/project.clj @@ -1,8 +1,8 @@ -(defproject simple-cloact "0.0.1" +(defproject simple-cloact "0.0.2-SNAPSHOT" :dependencies [[org.clojure/clojurescript "0.0-2120"] - [cloact "0.0.1"]] + [cloact "0.0.2-SNAPSHOT"]] :plugins [[lein-cljsbuild "1.0.0"]] :hooks [leiningen.cljsbuild] :profiles {:prod {:cljsbuild diff --git a/examples/todomvc/project.clj b/examples/todomvc/project.clj index af5eb6d..f37718d 100644 --- a/examples/todomvc/project.clj +++ b/examples/todomvc/project.clj @@ -1,8 +1,8 @@ -(defproject todomvc-cloact "0.0.1" +(defproject todomvc-cloact "0.0.2-SNAPSHOT" :dependencies [[org.clojure/clojurescript "0.0-2120"] - [cloact "0.0.1"]] + [cloact "0.0.2-SNAPSHOT"]] :plugins [[lein-cljsbuild "1.0.0"]] :hooks [leiningen.cljsbuild] :profiles {:prod {:cljsbuild diff --git a/examples/todomvc/src/todomvc.cljs b/examples/todomvc/src/todomvc.cljs index ab5d747..db75e84 100644 --- a/examples/todomvc/src/todomvc.cljs +++ b/examples/todomvc/src/todomvc.cljs @@ -22,7 +22,7 @@ nil)})]))) (def todo-input (with-meta todo-input-render - {:component-did-mount #(.focus (:dom-node %))})) + {:component-did-mount #(.focus (cloact/dom-node %))})) (defn todo-item [{:keys [todo on-toggle on-save on-destroy]} this] (dbg "Rendering item") diff --git a/project.clj b/project.clj index 90fd15d..f739f8b 100644 --- a/project.clj +++ b/project.clj @@ -1,6 +1,6 @@ -(defproject cloact "0.0.1" +(defproject cloact "0.0.2-SNAPSHOT" :dependencies [[org.clojure/clojurescript "0.0-2120"]] :plugins [[lein-cljsbuild "1.0.1"]] :hooks [leiningen.cljsbuild] diff --git a/src/cloact/core.cljs b/src/cloact/core.cljs index c9ac4ad..4a5ee7d 100644 --- a/src/cloact/core.cljs +++ b/src/cloact/core.cljs @@ -9,31 +9,52 @@ (def React tmpl/React) -(defn create-class [body] - (comp/create-class body)) - -(defn as-component [comp] - (tmpl/as-component comp)) +;; (defn as-component [comp] +;; (tmpl/as-component comp)) (defn render-component ([comp container] (render-component comp container nil)) ([comp container callback] - (.renderComponent React (as-component comp) container callback))) + (.renderComponent React (tmpl/as-component comp) container callback))) (defn unmount-component-at-node [container] (.unmountComponentAtNode React container)) (defn render-component-to-string [component callback] - (.renderComponentToString React (as-component component) callback)) + (.renderComponentToString React (tmpl/as-component component) callback)) -(defn set-props [C props] - (comp/set-props C props)) +(defn create-class [body] + (comp/create-class body)) -(defn replace-props [C props] - (comp/replace-props C props)) -(defn merge-props [defaults props] + +(defn set-props [comp props] + (comp/set-props comp props)) + +(defn replace-props [comp props] + (comp/replace-props comp props)) + + + +(defn props [comp] + (comp/get-props comp)) + +(defn children [comp] + (comp/get-children comp)) + +(defn dom-node [comp] + (.getDOMNode comp)) + +(defn refs [comp] + (.-refs comp)) + + + +(defn merge-props + "Utility function that merges two maps, handling :class and :style +specially, like React's transferPropsTo." + [defaults props] (util/merge-props defaults props)) diff --git a/src/cloact/impl/component.cljs b/src/cloact/impl/component.cljs index b922fdd..46d1d1a 100644 --- a/src/cloact/impl/component.cljs +++ b/src/cloact/impl/component.cljs @@ -14,8 +14,8 @@ (def -ToExtend (js-obj)) (set! (.-prototype -ToExtend) CloactMixin) -(declare get-props) -(declare get-children) +;; (declare get-props) +;; (declare get-children) (extend-type -ToExtend IEquiv @@ -39,17 +39,6 @@ (-add-watch [C key f] (assert false "Component isn't really watchable")) (-remove-watch [C key] (assert false "Component isn't really watchable")) - ILookup - (-lookup [C key] - (-lookup C key nil)) - (-lookup [C key not-found] - (case key - :props (get-props C) - :children (get-children C) - :dom-node (.getDOMNode C) - :refs (.-refs C) - not-found)) - IHash (-hash [C] (goog/getUid C))) @@ -103,7 +92,7 @@ (defn- do-render [C f] (set! (.-isRenderContext ratom/*ratom-context*) true) - (let [res (f (cljs-props C) C @C) + (let [res (f (cljs-props C) C) conv (if (vector? res) (tmpl/as-component res) (if (fn? res)