export function createBuffer()

in src/lib/api/event.recorder.ts [331:355]


export function createBuffer(root: ServerClientRoot): HTMLElement {
  const serverNode = root.serverNode;

  // if no rootServerNode OR the selector is on the entire html doc or the body
  // OR no parentNode, don't buffer
  if (!serverNode || !serverNode.parentNode ||
    serverNode === document.documentElement || serverNode === document.body) {
    return serverNode as HTMLElement;
  }

  // create shallow clone of server root
  const rootClientNode = serverNode.cloneNode(false) as HTMLElement;
  // we want the client to write to a hidden div until the time for switching
  // the buffers
  rootClientNode.style.display = 'none';

  // insert the client node before the server and return it
  serverNode.parentNode.insertBefore(rootClientNode, serverNode);

  // mark server node as not to be touched by AngularJS - needed for ngUpgrade
  serverNode.setAttribute('ng-non-bindable', '');

  // return the rootClientNode
  return rootClientNode;
}