     node)
   (-velem-simple-element [this] this)
   (-velem-insert [this vparent vnext-sibling]
-    (.ensureNode this)
-    (set! parent vparent)
-    (dom-insert parent node vnext-sibling)
+    (if-let [diff-head (get-diff-head)]
+      (ui/velem-replace this diff-head)
+      (do
+        (.ensureNode this)
+        (set! parent vparent)
+        (dom-insert parent node vnext-sibling)))
     this)
   (-velem-take [this]
     (dom-remove node)) 

  (-velem-simple-element [this] this)
  (-velem-insert [this vparent vnext-sibling]
    (set! parent vparent)
    (.ensureNode this)
    (dom-insert parent node vnext-sibling)
    (.onAttached this)
    this)
  (-velem-take [this]
    (dom-remove node)) 
  (-velem-replace [this old-velem]
    (.ensureNode this)
    (if-let [old-node (ui/velem-native-element old-velem)]
      (do
        (dom-simple-replace node old-node)
        (r/dispose old-velem))
      (dom-remove-replace node old-velem))
    (.onAttached this)
    this)
  (-velem-lifecycle-callback [this cb-name]


(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
