lib/collection.js
function wrap(nodes) {
  nodes = nodes || [];
  if ('string' == typeof nodes) {
    nodes = new DOMParser().parseFromString(nodes);
  }

  if (nodes.attrNS && nodes._related) {
    // attempt to re-wrap Collection, return it directly
    return nodes;
  } else if (nodes.documentElement) {
    nodes = [ nodes.documentElement ];
  } else if (nodes.nodeType) {
    nodes = [ nodes ];
  }
  return new Collection(nodes);
}
function wrap(nodes) {
  nodes = nodes || [];
  if ('string' == typeof nodes) {
    nodes = new DOMParser().parseFromString(nodes);
  }

  if (nodes.attrNS && nodes._related) {
    // attempt to re-wrap Collection, return it directly
    return nodes;
  } else if (nodes.documentElement) {
    nodes = [ nodes.documentElement ];
  } else if (nodes.nodeType) {
    nodes = [ nodes ];
  }
  return new Collection(nodes);
}
function wrap ( nodes ) { nodes = nodes || [ ] ; if ( 'string' == typeof nodes ) { nodes = new DOMParser ( ) . parseFromString ( nodes ) ; } if ( nodes . attrNS && nodes . _related ) { // attempt to re-wrap Collection, return it directly return nodes ; } else if ( nodes . documentElement ) { nodes = [ nodes . documentElement ] ; } else if ( nodes . nodeType ) { nodes = [ nodes ] ; } return new Collection ( nodes ) ; }
Wraps and returns a new collection of elements.

Examples:

$('<xml/>');

@param {String|Node|Collection|Array} nodes XML string or DOM nodes to wrap.
@return {Collection} The wrapped nodes.
@api public
Wraps and returns a new collection of elements .