 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
 (defn flatten-selectors
+  "Transforms a group of selectors as received from 
+  defselector to a group of pairs [selector action], 
+  removing nested selectors and putting all of them 
+  on the first level."
   ([actions] (partition 2 (flatten-selectors () actions)))
   ([base actions]
     (match [actions]

         true
         (html/has-class? dom-node class)))))

(defn- history-span [selector elem]
 (cond
   (html/dom-node? elem)
     (not (dom-matches-selector? elem selector))
   :else
     (not (= (symbol (.getName (type elem))) selector))))

(defn track-selector [selector history]
  (let [[new-history [elem & _]]
          (span #(history-span selector %) history)]
    (cond

(defn- matching-element [selector history]
  (first (select-element selector history)))

(defn selector-visitor 
  "Visitor middleware that will track all the elements on 
  the dalap walk tree that matches the given selectors."
  [selectors select-visit? visit-fn]
  (fn [elem w]
    (cond
      (not (select-visit? elem))
