code: function(array, spliceIdx, spliceCount, newElems, parent) {
    var spliceArgs = [spliceIdx, spliceCount].concat(newElems),
        prev = array[spliceIdx - 1] || null,
        next = array[spliceIdx] || null;
    var idx, len, prevIdx, node, oldParent;
  
    // Before splicing in new elements, ensure they do not already appear in the
    // current array.
    for (idx = 0, len = newElems.length; idx < len; ++idx) {
      node = newElems[idx];
      oldParent = node.parent || node.root;
      prevIdx = oldParent && oldParent.children.indexOf(newElems[idx]);
  
      if (oldParent && prevIdx > -1) {
        oldParent.children.splice(prevIdx, 1);
        if (parent === oldParent && spliceIdx > prevIdx) {
          spliceArgs[0]--;
        }
      }
  
      node.root = null;
      node.parent = parent;
  
      if (node.prev) {
        node.prev.next = node.next || null;
      }
  
      if (node.next) {
        node.next.prev = node.prev || null;
      }
  
      node.prev = newElems[idx - 1] || prev;
      node.next = newElems[idx + 1] || next;
    }
  
    if (prev) {
      prev.next = newElems[0];
    }
    if (next) {
      next.prev = newElems[newElems.length - 1];
    }
    return array.splice.apply(array, spliceArgs);
  }
docs: /*
  Modify an array in-place, removing some number of elements and adding new
  elements directly following them.
  
  @param {Array} array Target array to splice.
  @param {Number} spliceIdx Index at which to begin changing the array.
  @param {Number} spliceCount Number of elements to remove from the array.
  @param {Array} newElems Elements to insert into the array.
  
  @api private