Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

added set-prop as a new transfromation

  • Loading branch information...
commit 89f4febe2da89946f768dacd4f4dd43864421629 1 parent 5be2ee9
@ckirkendall authored
View
12 project/cljs-src/enfocus/core.cljs
@@ -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"
View
2  project/cljs-src/enfocus/enlive/syntax.cljs
@@ -54,3 +54,5 @@
(defn but [& sel]
(str "not(" (convert sel) ")"))
+
+
View
3  project/cljs-src/enfocus/example.cljs
@@ -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 [])
View
3  project/cljs-src/enfocus/macros.clj
@@ -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))
View
6 sample/resources/public/test.html
@@ -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>
Please sign in to comment.
Something went wrong with that request. Please try again.