Skip to content

Commit ecbe6ab

Browse files
committed
Checkbox's path property can be a sequence
1 parent a3a93e8 commit ecbe6ab

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

‎src/om_widgets/checkbox.cljs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
(:require [om.core :as om :include-macros true]
33
[schema.core :as s :include-macros true]
44
[sablono.core :refer-macros [html]]
5-
[om-widgets.utils :as utils]))
5+
[om-widgets.utils :as utils :refer [->seq]]))
66

77

88
(defn- checked?
@@ -31,7 +31,7 @@
3131
:checked (checked? (utils/om-get app path) checked-value)
3232
:onChange (fn [e]
3333
(let [value (if (.. e -target -checked) checked-value unchecked-value)
34-
dest (get @(om/get-props owner) path)]
34+
dest (get-in @(om/get-props owner) (->seq path))]
3535

3636
(if toggle-value
3737
(if (contains? dest checked-value)

‎src/om_widgets/utils.cljs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@
77
[cljs-time.format :as timef]))
88

99

10+
(defn ->seq
11+
"Ensures key is a sequence suitable for using with get-in"
12+
[path-or-key]
13+
(if (sequential? path-or-key)
14+
path-or-key
15+
[path-or-key]))
16+
1017
(defn make-childs
1118
"Build all alternative for sablono"
1219
[tag & childs]

0 commit comments

Comments
 (0)