Skip to content

Commit

Permalink
saving.
Browse files Browse the repository at this point in the history
  • Loading branch information
sritchie committed Dec 22, 2014
1 parent 825fa41 commit 183d797
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
2 changes: 1 addition & 1 deletion docs/src/clj/om_bootstrap/server.clj
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
(defn clojurescript []
(if (dev?)
(list
(h/include-js "http://fb.me/react-0.11.1.js")
(h/include-js "http://fb.me/react-0.12.2.js")
(h/include-js "static/generated/goog/base.js")
(h/include-js "static/assets/main.js")
(e/javascript-tag "goog.require(\"om_bootstrap.docs\");"))
Expand Down
4 changes: 2 additions & 2 deletions project.clj
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
[prismatic/om-tools "0.3.6" :exclusions [om]]
[prismatic/schema "0.3.1"
:exclusions [org.clojure/clojurescript]]
[om "0.7.1"]]
[om "0.8.0-beta5"]]
:profiles {:provided
{:dependencies [[org.clojure/clojurescript "0.0-2411"]
[secretary "1.2.0"]
Expand Down Expand Up @@ -53,7 +53,7 @@
:dependencies ~server-deps
:source-paths ["docs/src/clj"]
:resource-paths ["dev"]}
:om-8 {:dependencies [[om "0.8.0-beta3"]]}
:om-8 {:dependencies [[om "0.8.0-beta5"]]}
:dev {:plugins [[lein-cljsbuild "1.0.3"]
[com.cemerick/clojurescript.test "0.3.1"]
[paddleguru/lein-gitflow "0.1.2"]]
Expand Down
16 changes: 12 additions & 4 deletions src/om_bootstrap/util.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,11 @@
(aset ret k (aget arr k))))
ret))

(defn create-element
([child] (create-element child nil))
([child props]
(.createElement js/React (.-type child) props)))

(defn clone-om
"Merges the supplied extra properties into the underlying Om cursor
and calls the constructor to clone the React component.
Expand All @@ -129,7 +134,10 @@
(if (fn? extra-props)
(extra-props om-props)
(merge-props om-props extra-props))))
(.constructor child))))
(.createElement js/React (fn [& x]
(.log js/console "Getting " (js-keys child))
;; Closer! No copying's happening.
child)))))

(defn clone-basic-react
"This function is called if the React component child was NOT
Expand All @@ -142,7 +150,7 @@
(merge-props props extra-props))
(when-let [children (:children props)]
{:children children}))]
(.constructor child (clj->js new-props))))
(create-element child (clj->js new-props))))

(defn clone-with-props
"Returns a shallow copy of the supplied component (child); the copy
Expand All @@ -160,7 +168,7 @@
(clone-with-props child {}))
([child extra-props]
(cond (not (strict-valid-component? child)) child
(and (map? extra-props)
(empty? extra-props)) (.constructor child (.-props child))
(om-component? child) (clone-om child extra-props)
(and (map? extra-props)
(empty? extra-props)) (create-element child (.-props child))
:else (clone-basic-react child extra-props))))

0 comments on commit 183d797

Please sign in to comment.