src/DOM.js
function _cloneNode(deep, sourceNode, parentNode) {
  const clone = new sourceNode.constructor(sourceNode[symbols.windowSymbol]);
  clone.attrs = sourceNode.attrs;
  clone.tagName = sourceNode.tagName;
  clone.value = sourceNode.value;

  // Link the parent.
  if (parentNode) { clone.parentNode = parentNode; }

  // Copy children.
  if (deep) {
    clone.childNodes = new NodeList(
      sourceNode.childNodes.map(childNode =>
        _cloneNode(true, childNode, clone)
      )
    );
  }

  return clone;
}
function _cloneNode(deep, sourceNode, parentNode) {
  const clone = new sourceNode.constructor(sourceNode[symbols.windowSymbol]);
  clone.attrs = sourceNode.attrs;
  clone.tagName = sourceNode.tagName;
  clone.value = sourceNode.value;

  // Link the parent.
  if (parentNode) { clone.parentNode = parentNode; }

  // Copy children.
  if (deep) {
    clone.childNodes = new NodeList(
      sourceNode.childNodes.map(childNode =>
        _cloneNode(true, childNode, clone)
      )
    );
  }

  return clone;
}
function _cloneNode ( deep , sourceNode , parentNode ) { const clone = new sourceNode . constructor ( sourceNode [ symbols . windowSymbol ] ) ; clone . attrs = sourceNode . attrs ; clone . tagName = sourceNode . tagName ; clone . value = sourceNode . value ; // Link the parent. if ( parentNode ) { clone . parentNode = parentNode ; } // Copy children. if ( deep ) { clone . childNodes = new NodeList ( sourceNode . childNodes . map ( childNode => _cloneNode ( true , childNode , clone ) ) ) ; } return clone ; }
Clone node. Internal function to not expose the `sourceNode` and `parentNode` args
used to facilitate recursive cloning.

@param {boolean} deep - Recursive.
@param {object} sourceNode - Node to clone.
@param {parentNode} parentNode - Used for recursive cloning to attach parent.
Clone node . Internal function to not expose the sourceNode and parentNode args used to facilitate recursive cloning .