Fix merge-props without classes

This commit is contained in:
Anton Chikin 2020-03-07 00:23:30 +03:00
parent 84692f8633
commit bfca4e4d36
2 changed files with 8 additions and 1 deletions

View File

@ -147,7 +147,9 @@
rst)))
(defn- merge-class [p1 p2]
(assoc p2 :class (class-names (:class p1) (:class p2))))
(if-let [names (class-names (:class p1) (:class p2))]
(assoc p2 :class names)
p2))
(defn- merge-style [p1 p2]
(let [style (when-let [s1 (:style p1)]

View File

@ -56,6 +56,11 @@
(util/merge-props {:disabled true :style {:flex 1} :class "foo"}
{:disabled false :style {:flex-direction "row"} :class "bar"}))))
(testing "two arguments without classes"
(is (= {:disabled false :style {:flex 1 :flex-direction "row"}}
(util/merge-props {:disabled true :style {:flex 1}}
{:disabled false :style {:flex-direction "row"}}))))
(testing "n arguments"
(is (= {:disabled false
:checked true