mirror of https://github.com/status-im/reagent.git
Remove :> component type assertion
Component could be plain JS object with some private React properties, and it is not easy to check for this. Instead just allow all value for :> but check that React will throw error from createElement. Fixes #369
This commit is contained in:
parent
0c0ffc626a
commit
60f7b4bc0c
|
@ -387,8 +387,6 @@
|
||||||
0 (let [comp (nth v 1 nil)]
|
0 (let [comp (nth v 1 nil)]
|
||||||
;; Support [:> comp ...]
|
;; Support [:> comp ...]
|
||||||
(assert (= ">" n) (hiccup-err v "Invalid Hiccup tag"))
|
(assert (= ">" n) (hiccup-err v "Invalid Hiccup tag"))
|
||||||
(assert (or (string? comp) (fn? comp))
|
|
||||||
(hiccup-err v "Expected React component in"))
|
|
||||||
(native-element #js{:name comp} v 2))
|
(native-element #js{:name comp} v 2))
|
||||||
;; Support extended hiccup syntax, i.e :div.bar>a.foo
|
;; Support extended hiccup syntax, i.e :div.bar>a.foo
|
||||||
;; Apply metadata (e.g. :key) to the outermost element.
|
;; Apply metadata (e.g. :key) to the outermost element.
|
||||||
|
|
|
@ -962,9 +962,17 @@
|
||||||
(is (thrown-with-msg?
|
(is (thrown-with-msg?
|
||||||
:default #"Invalid Hiccup form: \[23]"
|
:default #"Invalid Hiccup form: \[23]"
|
||||||
(rstr [23])))
|
(rstr [23])))
|
||||||
(is (thrown-with-msg?
|
;; This used to be asserted by Reagent, but because it is hard to validate
|
||||||
:default #"Expected React component in: \[:> \[:div]]"
|
;; components, now we just trust React will validate elements.
|
||||||
(rstr [:> [:div]])))
|
; (is (thrown-with-msg?
|
||||||
|
; :default #"Expected React component in: \[:> \[:div]]"
|
||||||
|
; (rstr [:> [:div]])))
|
||||||
|
;; This is from React.createElement
|
||||||
|
(debug/track-warnings
|
||||||
|
(wrap-capture-console-error
|
||||||
|
#(is (thrown-with-msg?
|
||||||
|
:default #"Element type is invalid:"
|
||||||
|
(rstr [:> [:div]])))))
|
||||||
(is (thrown-with-msg?
|
(is (thrown-with-msg?
|
||||||
:default #"Invalid tag: 'p.'"
|
:default #"Invalid tag: 'p.'"
|
||||||
(rstr [:p.])))
|
(rstr [:p.])))
|
||||||
|
@ -1213,8 +1221,6 @@
|
||||||
(fn [v]
|
(fn [v]
|
||||||
(r/as-element [:div "Context: " v]))]])))))
|
(r/as-element [:div "Context: " v]))]])))))
|
||||||
|
|
||||||
;; FIXME: :> assertion broken
|
|
||||||
#_
|
|
||||||
(testing "context works with :>"
|
(testing "context works with :>"
|
||||||
(is (= "<div>Context: bar</div>"
|
(is (= "<div>Context: bar</div>"
|
||||||
(rstr [:> Provider {:value "bar"}
|
(rstr [:> Provider {:value "bar"}
|
||||||
|
|
Loading…
Reference in New Issue