src/vizone/vizone.js
// and newItem will be the only child of parentItem.
and newItem will be the only child of parentItem.
and newItem will be the only child of parentItem .
function vizone(fn, newItem, parentItem, forceRoot) {
  if (newItem.args) newItem.args = abbreviateArray(newItem.args);
  if (parentItem) {
    return vizone(vizone.bind(null, fn, newItem), parentItem, undefined, forceRoot);
  }
  if (forceRoot && zone.historyObj) {
    return zone.fork().run(vizone.bind(null, fn, parentItem, newItem));
  }
  var historyObj = zone.historyObj || {
        items: []
      };
  if (zone.historyObj) {
    newItem.$$$parent = zone.historyItem.$$$index;
    newItem.$$$zoneIndex = zone.historyObj.zoneIndex;
  } else {
    zone.history = zone.history || [];
    newItem.$$$zoneIndex = historyObj.zoneIndex = zone.history.length;
    zone.history.push(historyObj);
  }
  newItem.$$$index = historyObj.items.length;
  historyObj.items.push(newItem);
  vizoneDOM.appendToHistoryGraph(newItem);
  if (fn) {
    var fz = zone.fork();
    fz.historyObj = historyObj;
    fz.historyItem = newItem;
    return fz.run(fn);
  }
}
function vizone ( fn , newItem , parentItem , forceRoot ) { if ( newItem . args ) newItem . args = abbreviateArray ( newItem . args ) ; if ( parentItem ) { return vizone ( vizone . bind ( null , fn , newItem ) , parentItem , undefined , forceRoot ) ; } if ( forceRoot && zone . historyObj ) { return zone . fork ( ) . run ( vizone . bind ( null , fn , parentItem , newItem ) ) ; } var historyObj = zone . historyObj || { items : [ ] } ; if ( zone . historyObj ) { newItem . $$$parent = zone . historyItem . $$$index ; newItem . $$$zoneIndex = zone . historyObj . zoneIndex ; } else { zone . history = zone . history || [ ] ; newItem . $$$zoneIndex = historyObj . zoneIndex = zone . history . length ; zone . history . push ( historyObj ) ; } newItem . $$$index = historyObj . items . length ; historyObj . items . push ( newItem ) ; vizoneDOM . appendToHistoryGraph ( newItem ) ; if ( fn ) { var fz = zone . fork ( ) ; fz . historyObj = historyObj ; fz . historyItem = newItem ; return fz . run ( fn ) ; } }
and newItem will be the only child of parentItem.
and newItem will be the only child of parentItem .
// abbreviate args because we might expect args to be passed // along willy-nilly (like vizone.patch does) // inserting a parent item involves creating two separate // vizone calls // If the current zone already has a historyObj, we need // to create a new zone to force this item to be root // right now historyObj is just responsible for keeping // track of items. If there isn't a historyObj attached to the // current zone, create it now // child: // if we are inside of a viz-forked zone (a "leaf") then attach // this item to the tree // root: // if the current zone doesn't have a historyObj property, // this must be the root item // append item to the items array // fn is executed within the forked zone... // and this will return the result of fn()