Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for React.Fragment #907

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Add tests for dom/<>
  • Loading branch information
FieryCod committed Feb 9, 2019
commit ec895bfe114d9acd0770751b4bd0727f2e98541a
6 changes: 4 additions & 2 deletions src/main/om/dom.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -635,12 635,14 @@
:children children}))))

#?(:clj
(defn- is-element? [e]
(defn- is-element?
[e]
(or
(satisfies? p/IReactComponent e)
(satisfies? p/IReactDOMElement e))))

#?(:clj
(defn <> [& args]
(defn <>
[& args]
(let [children (if (is-element? (first args)) args (rest args))]
(vec children))))
8 changes: 8 additions & 0 deletions src/test/om/dom_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 506,14 @@
</div>
</div>"))))

(deftest render-react-fragment
(is (= (str (#'dom/render-to-str*
(dom/div #js {}
(dom/<> #js {}
(dom/input #js {:value "foo" :id "bar" :type "text"})
(dom/input #js {:value "foo" :id "bar" :type "text"})))))
"<div data-reactroot=\"\" data-reactid=\"1\"><input type=\"text\" value=\"foo\" id=\"bar\" data-reactid=\"2\"/><input type=\"text\" value=\"foo\" id=\"bar\" data-reactid=\"3\"/></div>")))

(deftest render-wrapped-attrs
(is (= (str (#'dom/render-to-str* (dom/input #js {:value "foo" :id "bar" :type "text"})))
"<input type=\"text\" value=\"foo\" id=\"bar\" data-reactroot=\"\" data-reactid=\"1\"/>"))
Expand Down