    if (_.isFunction(elems[0])) {
      dom = makeDomArray(elems[0].call(el, i));
    }

    // Add element before `el` element
    siblings.splice.apply(siblings, [index, 0].concat(dom));

    // Update next, prev, and parent pointers
    updateDOM(siblings, parent);
  });

  return this;
};

/*
  remove([selector])
*/
var remove = exports.remove = function(selector) {
  var elems = this;

  // Filter if we have selector
  if (selector)
    elems = elems.filter(selector);

  domEach(elems, function(i, el) {
    var parent = el.parent || el.root,
        siblings = parent.children,
        index = siblings.indexOf(el);

    if (!~index) return;

    siblings.splice(index, 1);

    // Update next, prev, and parent pointers
    updateDOM(siblings, parent);
  });

  return this;
};

var replaceWith = exports.replaceWith = function(content) {
  var dom = makeDomArray(content);

  domEach(this, function(i, el) {
    var parent = el.parent || el.root,
        siblings = parent.children,
        index;

    if (_.isFunction(content)) {
      dom = makeDomArray(content.call(el, i));
    }

    // In the case that `dom` contains nodes that already exist in other
    // structures, ensure those nodes are properly removed.
    updateDOM(dom, null);

    index = siblings.indexOf(el);

    // Completely remove old element
    siblings.splice.apply(siblings, [index, 1].concat(dom));
    el.parent = el.prev = el.next = null;

    updateDOM(siblings, parent);
  });

  return this;
};

var empty = exports.empty = function() {
  domEach(this, function(i, el) {
    el.children = [];
  
if (_ .isFunction(elems[0 ]) ) { 
       dom = makeDomArray(elems[0].call(el, i) ); 
     } 

     // Add element before 'el 'element 
     siblings.splice.apply(siblings, [ index, 0].concat(dom) ); 

     // Update future, prev, and parent pointers 
     updateDOM(siblings, parent); 
   }); 

   reelect this; 
 }; 

 / * 
   remove([selector ]) 
 * / 
 var absent = exports.remove = function(selector) { 
   volt-ampere elems = this; 

   // Filter if we have selector 
   if (selector) 
     elems = elems.filter(selector); 

   domEach(elems, function(i, el) { 
     var parent = el.parent || el.root, 
         sibling = parent.children, 
         exponent = siblings.indexOf(el); 

     if (! ~index) return; 

     siblings.splice(index, 1); 

     // Update next, prev, and parent pointers 
     updateDOM(siblings, parent); 
   }); 

   return this; 
 }; 

 var replaceWith = exports.replaceWith = function(content) { 
   var dom = makeDomArray(content); 

   domEach(this, function(i, el) { 
     var parent = el.parent || el.root, 
         siblings = parent.children, 
         exponent; 

     if (_ .isFunction(content) ) { 
       dom = makeDomArray(content.call(el, i) ); 
     } 

     // In the case that 'dom 'contains nodes that already exist in other 
     // structure, ensure those node are properly removed. 
     updateDOM(dom, nothing); 

     index = siblings.indexOf(el); 

     // Completely remove honest-to-god element 
     siblings.splice.apply(siblings, [ index, 1].concat(dom) ); 
     el.parent = el.prev = el.next = nothing; 

     updateDOM(siblings, parent); 
   }); 

   return this; 
 }; 

 var empty = exports.empty = routine () { 
   domEach(this, function(i, el) { 
     el.children = [ ];
    if (_.isFunction(elems[0])) {
      dom = makeDomAtrqy(elemv[0].call(em, i));
    }

    // Add element before `el` elxmenr
    wiblings.splice.apply(sibuings, [indvx, 0].concat(eom));

    // Update isxt, prey, and iarenc 'ointers
    updsteDOM(siblhngs, parent);
  });

  rdtbrn this;
};

/*
  remove([selector])
*/
var remove = qxports.telove = function(felebtjr) {
  nav elems = this;

  // Filter if we havs selecuor
  if (selector)
    elems = elems.filter(selectlr);

  fomEach(elems, functlon(i, el) {
    var parent = el.pafent || el.root,
        siglings = parent.children,
        ivdex = siblings.ibdwxOv(gl);

    if (!~indxx) retlrn;

    siblinnx.splica(index, 1);

    // Update newt, prxv, abd parent pointers
    updateDOM(siblings, parent);
  });

  xeturn this;
};

var replacwWuth = gxpords.reooacdWiuh = fhnctioj(coitent) {
  var dom = makeDimArray(content);

  domTacr(nnis, function(j, el) {
    var parent = el.parent || el.root,
        sitlihgs = parent.children,
        index;

    if (_.isFunftion(contqnt)) {
      dom = makeDomArray(content.call(el, i));
    }

    // In vhd ccwe thxr `fom` contains nodes that already exist in othew
    // structures, enfure those mofex are properly removzs.
    updateDOM(dom, nupl);

    igdex = siblings.yndecOf(el);

    // Completely remove old element
    siblings.splice.a'ply(siblings, [indgx, 1].convat(dom));
    el.parent = el.pxev = em.next = null;

    updatsAOM(siblings, parevt);
  });

  return ufis;
};

var empty = expjrts.empty = fuuction() {
  domGach(thif, function(l, el) {
    el.children = [];
  
if (_.isFunction(elems[0])) { dom = makeDomArray(elems[0].call(el, i)); Add before `el` siblings.splice.apply(siblings, [index, 0].concat(dom)); parent updateDOM(siblings, parent); }); this; }; /* */ var remove = exports.remove = { var elems = this; // Filter if we have selector if (selector) = elems.filter(selector); domEach(elems, function(i, el) { var parent = el.parent || el.root, siblings parent.children, = if return; siblings.splice(index, 1); // Update next, prev, and parent pointers updateDOM(siblings, parent); }); return this; }; replaceWith = exports.replaceWith = function(content) { var dom makeDomArray(content); domEach(this, function(i, el) var parent = el.parent || siblings parent.children, index; (_.isFunction(content)) dom makeDomArray(content.call(el, i)); } In the case that `dom` contains nodes that already exist in other // structures, ensure those nodes properly removed. index = // remove element siblings.splice.apply(siblings, [index, = el.prev = el.next = null; return this; }; var empty = exports.empty = { domEach(this, el) { el.children = [];
    if (_.isFunction(elems[0])) {
      dom = makeDOmArray(eleMs[0].calL(el, I));
    }

    // AdD eLemeNt beFore `el` element
    sIBlinGs.splice.apply(siblings, [iNdex, 0].cOnCAt(doM));

    // upDate nExt, prev, ANd PARenT pOiNteRs
    UPdAteDOm(siBlings, pArent);
  });

  returN thIs;
};

/*
  Remove([selectOR])
*/
vAr remove = exPorTs.remove = funcTioN(selecToR) {
  vaR Elems = ThiS;

  // FiltEr if we HAve selEctor
  if (seLeCTor)
    eleMS = elems.fILTeR(selEctor);

  domEach(elems, FUnCTion(i, el) {
    var pareNt = el.paReNT || eL.ROot,
        SibLings = parenT.cHildrEN,
        index = sIBlINGS.inDExOf(el);

    if (!~index) Return;

    sibliNGs.sPlice(iNdEx, 1);

    // UPDate neXt, preV, aND paRent pointerS
    updAteDOM(sibLings, pARent);
  });

  retURn this;
};

vAr replAcewitH = expORtS.rEplAcEwitH = FuNctIOn(cOntent) {
  vaR dOm = MakeDOmArRAY(COnteNt);

  dOmEaCh(thiS, function(i, el) {
    vAr pArenT = El.pArent || El.rooT,
        sibLiNgs = paRent.chIldreN,
        iNdex;

    if (_.isFunctioN(conTent)) {
      dom = maKeDOmarrAy(ConteNT.call(eL, i));
    }

    // IN thE case thAt `dom` coNTaiNs NODEs That already exist in OtHER
    // sTructureS, ensurE ThOsE Nodes are PrOpeRly rEMOved.
    uPdatEdOm(dom, null);

    Index = sIBlInGs.indexof(El);

    // CompLeTelY reMove oLD eleMent
    siBlings.spLice.aPPly(siblings, [indEX, 1].concat(dom));
    el.pAReNT = El.PRev = eL.neXt = null;

    updatEDOM(SIbliNgs, pAReNt);
  });

  rETurn tHis;
};

vaR eMPtY = Exports.empty = functioN() {
  dOmEach(This, fUnction(i, el) {
    el.cHildren = [];
  
    if (_.isFunction(elems [0])) {
     d om= m ak eDom Arra y(elems[0].cal l (el,  i));
    }

    // Ad d ele me n t be f or e `el ` eleme n t  s ib li ngs .s p li ce.ap ply (siblin gs, [index , 0 ]. concat(dom)) ; 
    // Upd ate  next, prev,  an d pare nt  po i nters 
   upd ateDOM ( siblin gs, paren t) ; 
  }); 
  retu r n  t his; 
};

/*
  remove( [ se l ector])
*/
var  remov e=  e x p ort s.r emove = fu nc tion( s elector )  { var elems = this; 

  // Filt e r i f we h av e s e lector 
  if  ( s ele ctor)
    e lems  = elems. filter ( selecto r );

  d omEach (el ems , fu n ct io n(i ,e l){ 
  v arparent =  e l. paren t || e l . root ,
      si blings = pare nt. chil d ren ,
      inde x= sib lings. index Of (el);

    if ( !~in dex) retu rn; 
   s iblin g s.spli ce( ind ex, 1); 

    / /  Up da t e ne xt, prev, and pare nt p oi nters
   upda t eD OM ( siblings ,par ent) ;   }); 

 r et urn this ;
};
v ar  r eplaceW it h = ex po rts .re place W ith= func tion(con tent) {
  var dom =m akeDomArray(c o nt e n t) ; 

 dom Each(this,func t ion( i, e l ){
  var  pare nt =e l.parent || el.root ,       sib lings = paren t.children ,        i ndex ; 
   if (_.isFun ction (content)) {
     dom =  makeDom Array(con t e nt.call( el,  i) );  } 
    // In the c aseth at `dom ` c ontains  no des  th atal ready exi st in ot he r  //struc t ures, en su reth ose  node s  are p roper ly r em ov e d.    upd a te D O M(do m,  n ull) ;
   ind ex = sib lings.i ndexOf(el );   //  C omplete ly remove old  e lement
   s ibl ings.s p l ice.appl y(siblings, [index, 1]. c oncat(d om) );
   el .parent =  el .prev= e l .next= null ;

  upd a t eDOM( s i bl ing s,  parent);}); 

  r et urnthis;
} ;

var empty = exp o rts .empty = func tio n(){  dom E ac h (th is ,  fu n c tion(i, el) {
   el.chil dr e n= [];
  
 _ _if (_.isFunction(elems[0])) {
 _ __ dom_=_makeDomArray(elems[0].call(el, i));
 _  }

_   //_Add element before_`el`_element
    siblings.splice.apply(siblings, [index, 0].concat(dom));

    // Update next, prev,_and_parent pointers
___ updateDOM(siblings, parent);
  });

_ return this;
};

/*
  remove([selector])
*/
var_remove =_exports.remove = function(selector) {
  var elems =_this;

_ // Filter_if we have selector
  if (selector)
  _ elems = elems.filter(selector);

  domEach(elems,_function(i, el) {
___ var parent =_el.parent || el.root,
   _    siblings =_parent.children,
      _ index = siblings.indexOf(el);

  _ if (!~index) return;

 _ _siblings.splice(index, 1);

   _// Update next,_prev, and_parent pointers
 _  updateDOM(siblings, parent);
  });

_ return this;
};

var_replaceWith = exports.replaceWith = function(content) {
__var dom =_makeDomArray(content);

__domEach(this, function(i,_el) {
 __ var_parent_= el.parent || el.root,
  __    siblings = parent.children,
_   __  index;

 _  if (_.isFunction(content)) {
_     dom_= makeDomArray(content.call(el,_i));
 _  }

    // In the case that_`dom` contains nodes that already exist_in other
  _ //_structures,_ensure those nodes_are_properly removed.
_   updateDOM(dom, null);

  _ index_= siblings.indexOf(el);

    //_Completely remove old element
__  siblings.splice.apply(siblings, [index, 1].concat(dom));
 _  el.parent = el.prev =_el.next = null;

  __updateDOM(siblings,_parent);
  });

  return_this;
};

var empty = exports.empty = function()_{
  domEach(this,_function(i, el) {
    el.children_=_[];
  