code: function replaceWith($rootElement, $element, newNode) {
        var oldNode = $element[0],
            parent = oldNode.parentNode,
            i, ii;
  
        if ($rootElement) {
          for(i = 0, ii = $rootElement.length; i < ii; i++) {
            if ($rootElement[i] == oldNode) {
              $rootElement[i] = newNode;
              break;
            }
          }
        }
  
        if (parent) {
          parent.replaceChild(newNode, oldNode);
        }
  
        newNode[jqLite.expando] = oldNode[jqLite.expando];
        $element[0] = newNode;
      }
docs: This is a special jqLite.replaceWith, which can replace items which
  have no parents, provided that the containing jqLite collection is provided.
  
  @param {JqLite=} $rootElement The root of the compile tree. Used so that we can replace nodes
  in the root of the tree.
  @param {JqLite} $element The jqLite element which we are going to replace. We keep the shell,
  but replace its DOM node reference.
  @param {Node} newNode The new DOM node.