mirror of https://github.com/status-im/reagent.git
parent
4a8ac5cd83
commit
606b321d2f
|
@ -122,12 +122,14 @@
|
|||
;; Merge classes
|
||||
class
|
||||
(assoc :class (let [old-class (:class props)]
|
||||
(if (nil? old-class) class (str class " " old-class)))))))
|
||||
(if (nil? old-class) class (str class " " (name old-class))))))))
|
||||
|
||||
(defn stringify-class [{:keys [class] :as props}]
|
||||
;; (keep name) doesn't work because class vector could contain false, which is not Named
|
||||
(if (coll? class)
|
||||
(->> class
|
||||
(filter identity)
|
||||
(map name)
|
||||
(string/join " ")
|
||||
(assoc props :class))
|
||||
props))
|
||||
|
|
|
@ -574,6 +574,22 @@
|
|||
(is (= (rstr [:p {:class #{"a" "b" "c"}}])
|
||||
(rstr [:p {:class "a b c"}]))))
|
||||
|
||||
(deftest class-named-values
|
||||
(is (= (rstr [:p {:class :a}])
|
||||
(rstr [:p {:class "a"}])))
|
||||
(is (= (rstr [:p.a {:class :b}])
|
||||
(rstr [:p {:class "a b"}])))
|
||||
(is (= (rstr [:p.a {:class 'b}])
|
||||
(rstr [:p {:class "a b"}])))
|
||||
(is (= (rstr [:p {:class [:a :b]}])
|
||||
(rstr [:p {:class "a b"}])))
|
||||
(is (= (rstr [:p {:class ['a :b]}])
|
||||
(rstr [:p {:class "a b"}])))
|
||||
|
||||
(testing "class collection can contain false value"
|
||||
(is (= (rstr [:p {:class [:a :b false nil]}])
|
||||
(rstr [:p {:class "a b"}])))) )
|
||||
|
||||
(deftest test-force-update
|
||||
(let [v (atom {:v1 0
|
||||
:v2 0})
|
||||
|
|
Loading…
Reference in New Issue