src/http/get-index/ssr.js
/**
 * Clone a node, and optionally its children.
 *
 * @param recursive Clone child nodes as well.
 * @returns A clone of the node.
 */
Clone a node, and optionally its children.
@param recursive Clone child nodes as well.
@returns A clone of the node.
Clone a node and optionally its children . @param recursive Clone child nodes as well . @returns A clone of the node .
function cloneNode(node, recursive) {
  if (recursive === void 0) {recursive = false;}
  var result;
  if (isText(node)) {
    result = new Text$2(node.data);
  } else
  if (isComment(node)) {
    result = new Comment$2(node.data);
  } else
  if (isTag$1(node)) {
    var children = recursive ? cloneChildren(node.children) : [];
    var clone_1 = new Element$2(node.name, __assign$1({}, node.attribs), children);
    children.forEach(function (child) {return child.parent = clone_1;});
    if (node["x-attribsNamespace"]) {
      clone_1["x-attribsNamespace"] = __assign$1({}, node["x-attribsNamespace"]);
    }
    if (node["x-attribsPrefix"]) {
      clone_1["x-attribsPrefix"] = __assign$1({}, node["x-attribsPrefix"]);
    }
    result = clone_1;
  } else
  if (isCDATA(node)) {
    var children = recursive ? cloneChildren(node.children) : [];
    var clone_2 = new NodeWithChildren(domelementtype_1$1.ElementType.CDATA, children);
    children.forEach(function (child) {return child.parent = clone_2;});
    result = clone_2;
  } else
  if (isDocument(node)) {
    var children = recursive ? cloneChildren(node.children) : [];
    var clone_3 = new Document$2(children);
    children.forEach(function (child) {return child.parent = clone_3;});
    if (node["x-mode"]) {
      clone_3["x-mode"] = node["x-mode"];
    }
    result = clone_3;
  } else
  if (isDirective(node)) {
    var instruction = new ProcessingInstruction(node.name, node.data);
    if (node["x-name"] != null) {
      instruction["x-name"] = node["x-name"];
      instruction["x-publicId"] = node["x-publicId"];
      instruction["x-systemId"] = node["x-systemId"];
    }
    result = instruction;
  } else
  {
    throw new Error("Not implemented yet: " + node.type);
  }
  result.startIndex = node.startIndex;
  result.endIndex = node.endIndex;
  return result;
}
function cloneNode ( node , recursive ) { if ( recursive === void 0 ) { recursive = false ; } var result ; if ( isText ( node ) ) { result = new Text$2 ( node . data ) ; } else if ( isComment ( node ) ) { result = new Comment$2 ( node . data ) ; } else if ( isTag$1 ( node ) ) { var children = recursive ? cloneChildren ( node . children ) : [ ] ; var clone_1 = new Element$2 ( node . name , __assign$1 ( { } , node . attribs ) , children ) ; children . forEach ( function ( child ) { return child . parent = clone_1 ; } ) ; if ( node [ "x-attribsNamespace" ] ) { clone_1 [ "x-attribsNamespace" ] = __assign$1 ( { } , node [ "x-attribsNamespace" ] ) ; } if ( node [ "x-attribsPrefix" ] ) { clone_1 [ "x-attribsPrefix" ] = __assign$1 ( { } , node [ "x-attribsPrefix" ] ) ; } result = clone_1 ; } else if ( isCDATA ( node ) ) { var children = recursive ? cloneChildren ( node . children ) : [ ] ; var clone_2 = new NodeWithChildren ( domelementtype_1$1 . ElementType . CDATA , children ) ; children . forEach ( function ( child ) { return child . parent = clone_2 ; } ) ; result = clone_2 ; } else if ( isDocument ( node ) ) { var children = recursive ? cloneChildren ( node . children ) : [ ] ; var clone_3 = new Document$2 ( children ) ; children . forEach ( function ( child ) { return child . parent = clone_3 ; } ) ; if ( node [ "x-mode" ] ) { clone_3 [ "x-mode" ] = node [ "x-mode" ] ; } result = clone_3 ; } else if ( isDirective ( node ) ) { var instruction = new ProcessingInstruction ( node . name , node . data ) ; if ( node [ "x-name" ] != null ) { instruction [ "x-name" ] = node [ "x-name" ] ; instruction [ "x-publicId" ] = node [ "x-publicId" ] ; instruction [ "x-systemId" ] = node [ "x-systemId" ] ; } result = instruction ; } else { throw new Error ( "Not implemented yet: " + node . type ) ; } result . startIndex = node . startIndex ; result . endIndex = node . endIndex ; return result ; }
Clone a node, and optionally its children.
Clone a node and optionally its children .