Permalink
Browse files

added set-prop as a new transfromation

  • Loading branch information...
1 parent 5be2ee9 commit 89f4febe2da89946f768dacd4f4dd43864421629 @ckirkendall committed Jul 29, 2012
@@ -286,14 +286,20 @@
[& values]
(let [pairs (partition 2 values)]
(domina-chain
- #(doseq [[name value] pairs] (domina/set-attr! % name value)))))
-
+ #(doseq [[name value] pairs] (domina/set-attr! % name value)))))
(defn en-remove-attr
"Dissocs attributes on the selected element."
[& values]
(domina-chain #(doseq [name values] (domina/remove-attr! % name))))
-
+
+
+(defn en-set-prop [& forms]
+ (chainable-standard
+ (fn [node]
+ (let [h (mapcat (fn [[n v]](list (name n) v)) (partition 2 forms))]
+ (dom/setProperties node (apply js-obj h))))))
+
(defn- has-class
"returns true if the element has a given class"
@@ -54,3 +54,5 @@
(defn but [& sel]
(str "not(" (convert sel) ")"))
+
+
@@ -148,7 +148,8 @@
["#mv-tst"] (em/move 300 305 500
(em/move 0 0 500))))
["#test-from"] (em/listen :click test-from)
- ["#test-get-text"] (em/listen :click test-get-text))
+ ["#test-get-text"] (em/listen :click test-get-text)
+ ["#cb1"] (em/set-prop :checked true))
;(em/defaction test-suite [])
@@ -131,10 +131,11 @@
(defmacro set-attr [& forms]
`(enfocus.core/en-set-attr ~@forms))
-
(defmacro remove-attr [& forms]
`(enfocus.core/en-remove-attr ~@forms))
+(defmacro set-prop [& forms]
+ `(enfocus.core/en-set-prop ~@forms))
(defmacro add-class [& forms]
`(enfocus.core/en-add-class ~@forms))
@@ -46,9 +46,9 @@
<form id="from-form">
<input id="ftest1" name="test1" value="Testing1"/><br>
<input id="ftest2" name="test2" value="Testing2"/><br>
- one<input name="test3" type="checkbox" value="one">
- two<input name="test3" type="checkbox" value="two">
- three<input name="test3" type="checkbox" value="thee"><br>
+ one<input id="cb1" name="test3" type="checkbox" value="one">
+ two<input id="cb2" name="test3" type="checkbox" value="two">
+ three<input id="cb3" name="test3" type="checkbox" value="thee"><br>
<select name="test4" multiple="multiple">
<option value="ten">ten</option>
<option value="twenty">twenty</option>

0 comments on commit 89f4feb

Please sign in to comment.