Avoid unnecessary warning about missing :key

:key is not necessary in seqs in render-to-string et al.
This commit is contained in:
Dan Holmsand 2015-07-31 16:18:51 +02:00
parent b2210c2bf3
commit 51048c7a7f
2 changed files with 11 additions and 1 deletions

View File

@ -282,7 +282,8 @@
(warn "Reactive deref not supported in lazy seq, "
"it should be wrapped in doall"
(comp/comp-name) ". Value:\n" (pr-str x)))
(when (.' ctx :no-key)
(when (and (not comp/*non-reactive*)
(.' ctx :no-key))
(warn "Every element in a seq should have a unique "
":key" (comp/comp-name) ". Value: " (pr-str x)))
res))

View File

@ -516,3 +516,12 @@
(rstr [:div.foo [:p.bar.foo [:b.foobar "xy"]]])))
(is (= (rstr [:div>p.bar.foo>a.foobar {:href "href"} "xy"])
(rstr [:div [:p.bar.foo [:a.foobar {:href "href"} "xy"]]]))))
(deftest test-key-warning
;; Just make sure that seq without key dont print unnecessary
;; debug messages
(r/render-to-static-markup [:div (for [x (range 5)]
[:p x])])
(r/render-to-string [:div (for [x (range 5)]
[:p x])]))