src/basis/dom.js
function insert(node, source, insertPoint, refChild){
    node = get(node) || node; // TODO: remove

    switch (insertPoint) {
      case undefined: // insertPoint omitted
      case INSERT_END:
        refChild = null;
      break;
      case INSERT_BEGIN:
        refChild = node[FIRST_CHILD];
      break;
      case INSERT_BEFORE:
      break;
      case INSERT_AFTER:
        refChild = refChild[NEXT_SIBLING];
      break;
      default:
        insertPoint = Number(insertPoint);
        refChild = insertPoint >= 0 && insertPoint < node.childNodes.length ? node.childNodes[insertPoint] : null;
    }

    var isDOMLikeObject = !isNode(node);
    var result;

    if (!source || !Array.isArray(source))
      result = isDOMLikeObject ? source && node.insertBefore(source, refChild) : handleInsert(node, source, refChild);
    else
    {
      if (isDOMLikeObject)
      {
        result = [];
        for (var i = 0, len = source.length; i < len; i++)
          result[i] = node.insertBefore(source[i], refChild);
      }
      else
      {
        node.insertBefore(createFragment.apply(0, source), refChild);
        result = createFragment.array;
      }
    }

    return result;
  }
function insert(node, source, insertPoint, refChild){
    node = get(node) || node; // TODO: remove

    switch (insertPoint) {
      case undefined: // insertPoint omitted
      case INSERT_END:
        refChild = null;
      break;
      case INSERT_BEGIN:
        refChild = node[FIRST_CHILD];
      break;
      case INSERT_BEFORE:
      break;
      case INSERT_AFTER:
        refChild = refChild[NEXT_SIBLING];
      break;
      default:
        insertPoint = Number(insertPoint);
        refChild = insertPoint >= 0 && insertPoint < node.childNodes.length ? node.childNodes[insertPoint] : null;
    }

    var isDOMLikeObject = !isNode(node);
    var result;

    if (!source || !Array.isArray(source))
      result = isDOMLikeObject ? source && node.insertBefore(source, refChild) : handleInsert(node, source, refChild);
    else
    {
      if (isDOMLikeObject)
      {
        result = [];
        for (var i = 0, len = source.length; i < len; i++)
          result[i] = node.insertBefore(source[i], refChild);
      }
      else
      {
        node.insertBefore(createFragment.apply(0, source), refChild);
        result = createFragment.array;
      }
    }

    return result;
  }
function insert ( node , source , insertPoint , refChild ) { node = get ( node ) || node ; // TODO: remove switch ( insertPoint ) { case undefined : // insertPoint omitted case INSERT_END : refChild = null ; break ; case INSERT_BEGIN : refChild = node [ FIRST_CHILD ] ; break ; case INSERT_BEFORE : break ; case INSERT_AFTER : refChild = refChild [ NEXT_SIBLING ] ; break ; default : insertPoint = Number ( insertPoint ) ; refChild = insertPoint >= 0 && insertPoint < node . childNodes . length ? node . childNodes [ insertPoint ] : null ; } var isDOMLikeObject = ! isNode ( node ) ; var result ; if ( ! source || ! Array . isArray ( source ) ) result = isDOMLikeObject ? source && node . insertBefore ( source , refChild ) : handleInsert ( node , source , refChild ) ; else { if ( isDOMLikeObject ) { result = [ ] ; for ( var i = 0 , len = source . length ; i < len ; i ++ ) result [ i ] = node . insertBefore ( source [ i ] , refChild ) ; } else { node . insertBefore ( createFragment . apply ( 0 , source ) , refChild ) ; result = createFragment . array ; } } return result ; }
DOM manipulations  
Insert source into specified insertPoint position of node.
@param {Node|object} node Destination node.
@param {Node|Array.<Node>|object|Array.<object>} source One or more nodes to be inserted.
@param {string|number=} insertPoint Number as value means position in nodes childNodes.
Also it might be one of special value: INSERT_BEGIN, INSERT_BEFORE, INSERT_AFTER, INSERT_END.
@param {Node|object=} refChild Pointer to Child node of node, using for INSERT_BEFORE & INSERT_AFTER
@return {Node|Array.<Node>} Inserted nodes (may different of source members).
DOM manipulations Insert source into specified insertPoint position of node .