From 37b2954c3ad9b20e321ae144336ae478cf4c0efa Mon Sep 17 00:00:00 2001 From: Dan Holmsand Date: Fri, 29 Apr 2016 09:13:55 +0200 Subject: [PATCH] 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. --- src/reagent/impl/template.cljs | 2 ++ test/reagenttest/testreagent.cljs | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/src/reagent/impl/template.cljs b/src/reagent/impl/template.cljs index 1916ea6..98b7dab 100644 --- a/src/reagent/impl/template.cljs +++ b/src/reagent/impl/template.cljs @@ -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] diff --git a/test/reagenttest/testreagent.cljs b/test/reagenttest/testreagent.cljs index edbc487..b8ce1f0 100644 --- a/test/reagenttest/testreagent.cljs +++ b/test/reagenttest/testreagent.cljs @@ -956,3 +956,9 @@ (deftest test-empty-input (is (= "
" (rstr [:div [:input]])))) + +(deftest test-object-children + (is (= "

foo bar1

" + (rstr [:p 'foo " " :bar nil 1]))) + (is (= "

#<Atom: 1>

" + (rstr [:p (r/atom 1)]))))