Allow symbols, keywords and arbitrary cljs objects in markup

React no longer defaults to applying toString, and instead throws
confusing error messages when it encounters non-element objects.

This should make that happen less often.
This commit is contained in:
Dan Holmsand 2016-04-29 09:13:55 +02:00
parent 635e7c6e2a
commit 37b2954c3a
2 changed files with 8 additions and 0 deletions

View File

@ -318,6 +318,8 @@
(seq? x) (if (dev?)
(expand-seq-check x)
(expand-seq x))
(named? x) (name x)
(satisfies? IPrintWithWriter x) (pr-str x)
:else x))
(defn expand-seq [s]

View File

@ -956,3 +956,9 @@
(deftest test-empty-input
(is (= "<div><input/></div>"
(rstr [:div [:input]]))))
(deftest test-object-children
(is (= "<p>foo bar1</p>"
(rstr [:p 'foo " " :bar nil 1])))
(is (= "<p>#&lt;Atom: 1&gt;</p>"
(rstr [:p (r/atom 1)]))))