Work around clojurescript problem with sorted-maps

This commit is contained in:
Dan Holmsand 2015-08-31 08:18:45 +02:00
parent 4ccec97274
commit b77b182d67
2 changed files with 12 additions and 1 deletions

View File

@ -215,7 +215,11 @@
(fn-to-class tag)))
(defn get-key [x]
(when (map? x) (get x :key)))
(when (map? x)
;; try catch to avoid clojurescript peculiarity with
;; sorted-maps with keys that are numbers
(try (get x :key)
(catch :default e))))
(defn key-from-vec [v]
(if-some [k (some-> (meta v) get-key)]

View File

@ -552,3 +552,10 @@
(fn [c]
(is (seq @a))
(is (re-find #"atestcomponent" @a) "component-path should work")))))
(deftest test-sorted-map-key
(let [c1 (fn [map]
[:div (map 1)])
c2 (fn []
[c1 (sorted-map 1 "foo" 2 "bar")])]
(is (= (rstr [c2]) "<div>foo</div>"))))