Created
March 19, 2015 17:09
-
-
Save ostronom/c2f99c9de7f0196043df to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn canonical-input-value [input] | |
(case (.toLowerCase (.getAttribute input "type")) | |
"checkbox" (.-checked input) | |
"textarea" (.-innerHTML input) | |
(.-value input))) | |
(defn input-pair [input] | |
[(.getAttribute input "name") (canonical-input-value input)]) | |
(defn is-file? [input] | |
(= (.getAttribute input "type") "file")) | |
(defn fetch-form-values [form] | |
(into {} (comp (remove is-file?) (map input-pair)) (.querySelectorAll form "input[name]"))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment