mirror of https://github.com/status-im/reagent.git
Merge branch 'achikin-merge-props-fix'
This commit is contained in:
commit
e83043b2f9
|
@ -147,7 +147,9 @@
|
|||
rst)))
|
||||
|
||||
(defn- merge-class [p1 p2]
|
||||
(assoc p2 :class (class-names (:class p1) (:class p2))))
|
||||
(if (or (contains? p1 :class) (contains? p2 :class))
|
||||
(assoc p2 :class (class-names (:class p1) (:class p2)))
|
||||
p2))
|
||||
|
||||
(defn- merge-style [p1 p2]
|
||||
(let [style (when-let [s1 (:style p1)]
|
||||
|
|
|
@ -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
|
||||
|
@ -82,7 +87,9 @@
|
|||
(util/merge-props {:class "foo bar"}
|
||||
{:class ["baz" "quux"]})
|
||||
(util/merge-props nil {:class ["foo" "bar" "baz" "quux"]})
|
||||
(util/merge-props {:class ["foo" "bar" "baz" "quux"]})))))
|
||||
(util/merge-props {:class ["foo" "bar" "baz" "quux"]} nil)
|
||||
(util/merge-props {:class ["foo" "bar" "baz" "quux"]})
|
||||
(util/merge-props {:class "foo bar"} {:class ["baz"]} {:class ["quux"]})))))
|
||||
|
||||
(deftest partial-fn-test
|
||||
(is (= (util/make-partial-fn println ["a"])
|
||||
|
|
Loading…
Reference in New Issue