         (set! (.-parent-state state) parent-state)
         (register-with-parent-state parent-state (get-node-id new-elem) state)))))
 
-(defn- replace-node-completly [parent new-elem-spec cur-dom-node]
-  (let [new-elem (build-element new-elem-spec)]
+(defn- replace-node-completely [parent new-elem-spec cur-dom-node top-level]
+  (let [new-elem
+        (if top-level
+          (do
+            ;(println "build")
+            (build-element new-elem-spec))
+          (build-element new-elem-spec))]
     (register-element-with-parent parent new-elem)
     (.replaceChild parent new-elem cur-dom-node)
     (dispose-node cur-dom-node)

                              (dispose-node child-key state)))))))

(defn- remove-dom-node [dom-node]
  (time
    (let [state (aget element-state-lookup dom-node)]
      (dispose-node dom-node state)
      (when-let [parent (.-parentNode dom-node)]
        (.removeChild parent dom-node)
        (when state
          (js-delete (.-parent-state state) state))))))

(defn remove! [x]
  (if (dom-node? x)

               (set! (.-dirty state) true)
               (when-not (.-updating state)
                 (set! (.-updating state) true)
                 (queue-animation animate)))))

          binding-invalidated (:binding-invalidated ref-meta)

          invalidate (if binding-invalidated
                       (fn binding-invalidated-wrapper
                         ([key child-ref _ _] (binding-invalidated-wrapper key child-ref))
                         ([key child-ref]
                          (when (binding-invalidated (.-cur-element state) child-ref)
                            (invalidate key child-ref))))
                       invalidate)]
      (set! (.-animate state) animate)
      (set! (.-invalidate state) invalidate)
      (when-let [binding-disposed (get (meta child-ref) :binding-disposed)]
        (set! (.-disposed-callback state) binding-disposed))
      (when-let [parent-state (get-element-state parent)]
        (register-with-parent-state parent-state id state))
      (when-let [binding-initialized (get (meta child-ref)
                                          :binding-initialized)]
        (binding-initialized))
