 
 (def ^:private bind-attrs! (wrap-attr-map-binder bind-attr!))
 
+(def ^:private enable-diffing false)
+
+(defn enable-diffing!
+  "Enables experimental diffing support."
+  ([] (enable-diffing! true))
+  ([enable] (set! enable-diffing enable)))
+
+(def ^:private ^:dynamic *diff-head* nil)
+
+(defn- get-diff-head* []
+  (when-let [head *diff-head*]
+    (set! *diff-head* (.-nextSibling head))
+    head))
+
+(defn- get-diff-head []
+  (when-let [head (get-diff-head*)]
+    (or (get-element-state head)
+        (UnmanagedDOMNode. head nil nil))))
+
 (deftype DOMElement [ns-uri tag ^:mutable attrs children ^:mutable node
                      ^:mutable parent ^:mutable attr-binder]
   IHash

    (when handler
      (unlisten! node event-name handler)))
  (dispose [this]
    (.unlisten this)
    (set! (.-disposed this) true)))

(defn- bind-event! [node event-name handler]
  ((EventBinding. node (name event-name) nil) handler))


  Object
  (dispose [this]
    (when attr-binder (r/dispose attr-binder))
    (dotimes [i (.-length children)]
      (r/dispose (aget children i))))
  (ensureNode [this]
    (when-not node
