mirror of https://github.com/status-im/reagent.git
Fix #399, fix React key check with :> shortcut
This commit is contained in:
parent
3ee1d65aa5
commit
68531569c0
|
@ -5,6 +5,7 @@
|
|||
- Fixed merge-props adding `:class` property to result even if no argument
|
||||
defined `:class` ([#479](https://github.com/reagent-project/reagent/pull/479))
|
||||
- Fix using `:className` property together with keyword class shortcut ([#433](https://github.com/reagent-project/reagent/issues/433))
|
||||
- Fix incorrect missing React key warnings with `:>` ([#399](https://github.com/reagent-project/reagent/issues/399))
|
||||
|
||||
## 0.10.0 (2020-03-06)
|
||||
|
||||
|
|
|
@ -287,7 +287,11 @@
|
|||
(defn key-from-vec [v]
|
||||
(if-some [k (-> (meta v) get-key)]
|
||||
k
|
||||
(-> v (nth 1 nil) get-key)))
|
||||
(or (-> v (nth 1 nil) get-key)
|
||||
;; :> is a special case because properties map is the first
|
||||
;; element of the vector.
|
||||
(if (= :> (nth v 0 nil))
|
||||
(get-key (nth v 2 nil))))))
|
||||
|
||||
(defn reag-element [tag v]
|
||||
(let [c (comp/as-class tag)
|
||||
|
|
|
@ -22,3 +22,8 @@
|
|||
(tmpl/convert-props {:class "a"} (tmpl/HiccupTag. nil nil nil true))))
|
||||
(is (js-equal? #js {:className "a b" :id "a"}
|
||||
(tmpl/convert-props {:class "b"} (tmpl/HiccupTag. nil "a" "a" false)))))
|
||||
|
||||
(deftest key-from-vec-test
|
||||
(is (= 1 (tmpl/key-from-vec ^{:key 1} [:foo "bar"])))
|
||||
(is (= 1 (tmpl/key-from-vec [:foo {:key 1} "bar"])))
|
||||
(is (= 1 (tmpl/key-from-vec [:> "div" {:key 1} "bar"]))))
|
||||
|
|
|
@ -523,6 +523,14 @@
|
|||
(is (= (rstr [:div "a" "b" [:div "c"]])
|
||||
(rstr [:> d2 "a" "b" [:div "c"]])))))
|
||||
|
||||
(deftest adapt-react-class-shortcut-key-warning
|
||||
(let [w (debug/track-warnings
|
||||
#(with-mounted-component [:div
|
||||
(list
|
||||
[:> "div" {:key 1} "a"]
|
||||
[:> "div" {:key 2} "b"])]
|
||||
(fn [c div])))]
|
||||
(is (empty? (:warn w)))))
|
||||
|
||||
(deftest test-reactize-component
|
||||
(let [ae r/as-element
|
||||
|
|
Loading…
Reference in New Issue