(defn parse-selector [s]
(loop [matches (re-seq #"([#.])?([^#.]+)" (name s))
tag "div"
id nil
classes nil]
(if-let [[_ prefix val] (first matches)]
(case prefix
nil (recur (next matches) val id classes)
"#" (recur (next matches) tag val classes)
"." (recur (next matches) tag id (conj (or classes []) val)))
[tag id classes])))