diff --git a/CHANGELOG.md b/CHANGELOG.md index 3075b96..3a21551 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,9 @@ - Fix problem which caused using e.g. `:class` property with custom HTML element to break normal elements - Fix problem using keyword or symbol as `:class` together with element tag class shorthand, e.g. `[:p.a {:class :b}]` ([#367](https://github.com/reagent-project/reagent/issues/367)) - Added support for using keywords and symbols in `:class` collection +- Removed component type assertion for `:>` (#[369](https://github.com/reagent-project/reagent/issues/369), [#372](https://github.com/reagent-project/reagent/pull/372))) + - This caused problems with React Context where component is Plain JS object with special properties + - `React/createElement` will still provide error if `:>` is used with invalid values ## 0.8.0 (2018-04-19) diff --git a/src/reagent/impl/template.cljs b/src/reagent/impl/template.cljs index 416f27d..c20e130 100644 --- a/src/reagent/impl/template.cljs +++ b/src/reagent/impl/template.cljs @@ -383,11 +383,10 @@ pos (.indexOf n ">")] (case pos -1 (native-element (cached-parse n) v 1) + ;; TODO: Doesn't this match :>foo or any keyword starting with > 0 (let [comp (nth v 1 nil)] ;; Support [:> comp ...] (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)) ;; Support extended hiccup syntax, i.e :div.bar>a.foo ;; Apply metadata (e.g. :key) to the outermost element. diff --git a/test/reagenttest/testreagent.cljs b/test/reagenttest/testreagent.cljs index d965935..00266c1 100644 --- a/test/reagenttest/testreagent.cljs +++ b/test/reagenttest/testreagent.cljs @@ -962,9 +962,19 @@ (is (thrown-with-msg? :default #"Invalid Hiccup form: \[23]" (rstr [23]))) - (is (thrown-with-msg? - :default #"Expected React component in: \[:> \[:div]]" - (rstr [:> [:div]]))) + ;; This used to be asserted by Reagent, but because it is hard to validate + ;; components, now we just trust React will validate elements. + ; (is (thrown-with-msg? + ; :default #"Expected React component in: \[:> \[:div]]" + ; (rstr [:> [:div]]))) + ;; This is from React.createElement + ;; NOTE: browser-npm uses production cjs bundle for now which only shows + ;; the minified error + (debug/track-warnings + (wrap-capture-console-error + #(is (thrown-with-msg? + :default #"(Element type is invalid:|Minified React error)" + (rstr [:> [:div]]))))) (is (thrown-with-msg? :default #"Invalid tag: 'p.'" (rstr [:p.]))) @@ -1182,3 +1192,40 @@ [children])])] (is (= "