src/basis/data.js
function applyDelegateChanges(object, oldRoot, oldTarget){
    var delegate = object.delegate;

    if (delegate)
    {
      object.root = delegate.root;
      object.target = delegate.target;
      object.data = delegate.data;
      object.state = delegate.state;
    }

    // fire event if root changed
    if (!isEqual(object.root, oldRoot))
    {
      var rootListenHandler = object.listen.root;

      if (rootListenHandler)
      {
        if (oldRoot && !isEqual(oldRoot, object))
          oldRoot.removeHandler(rootListenHandler, object);

        if (object.root && !isEqual(object.root, object))
          object.root.addHandler(rootListenHandler, object);
      }

      object.emit_rootChanged(oldRoot);
    }

    // fire event if target changed
    if (!isEqual(object.target, oldTarget))
    {
      var targetListenHandler = object.listen.target;

      if (targetListenHandler)
      {
        if (oldTarget && !isEqual(oldTarget, object))
          oldTarget.removeHandler(targetListenHandler, object);

        if (object.target && !isEqual(object.target, object))
          object.target.addHandler(targetListenHandler, object);
      }

      object.emit_targetChanged(oldTarget);
    }

    var cursor = object.delegates_;
    while (cursor)
    {
      if (cursor.delegate)
        applyDelegateChanges(cursor.delegate, oldRoot, oldTarget);
      cursor = cursor.next;
    }
  }
function applyDelegateChanges(object, oldRoot, oldTarget){
    var delegate = object.delegate;

    if (delegate)
    {
      object.root = delegate.root;
      object.target = delegate.target;
      object.data = delegate.data;
      object.state = delegate.state;
    }

    // fire event if root changed
    if (!isEqual(object.root, oldRoot))
    {
      var rootListenHandler = object.listen.root;

      if (rootListenHandler)
      {
        if (oldRoot && !isEqual(oldRoot, object))
          oldRoot.removeHandler(rootListenHandler, object);

        if (object.root && !isEqual(object.root, object))
          object.root.addHandler(rootListenHandler, object);
      }

      object.emit_rootChanged(oldRoot);
    }

    // fire event if target changed
    if (!isEqual(object.target, oldTarget))
    {
      var targetListenHandler = object.listen.target;

      if (targetListenHandler)
      {
        if (oldTarget && !isEqual(oldTarget, object))
          oldTarget.removeHandler(targetListenHandler, object);

        if (object.target && !isEqual(object.target, object))
          object.target.addHandler(targetListenHandler, object);
      }

      object.emit_targetChanged(oldTarget);
    }

    var cursor = object.delegates_;
    while (cursor)
    {
      if (cursor.delegate)
        applyDelegateChanges(cursor.delegate, oldRoot, oldTarget);
      cursor = cursor.next;
    }
  }
function applyDelegateChanges ( object , oldRoot , oldTarget ) { var delegate = object . delegate ; if ( delegate ) { object . root = delegate . root ; object . target = delegate . target ; object . data = delegate . data ; object . state = delegate . state ; } // fire event if root changed if ( ! isEqual ( object . root , oldRoot ) ) { var rootListenHandler = object . listen . root ; if ( rootListenHandler ) { if ( oldRoot && ! isEqual ( oldRoot , object ) ) oldRoot . removeHandler ( rootListenHandler , object ) ; if ( object . root && ! isEqual ( object . root , object ) ) object . root . addHandler ( rootListenHandler , object ) ; } object . emit_rootChanged ( oldRoot ) ; } // fire event if target changed if ( ! isEqual ( object . target , oldTarget ) ) { var targetListenHandler = object . listen . target ; if ( targetListenHandler ) { if ( oldTarget && ! isEqual ( oldTarget , object ) ) oldTarget . removeHandler ( targetListenHandler , object ) ; if ( object . target && ! isEqual ( object . target , object ) ) object . target . addHandler ( targetListenHandler , object ) ; } object . emit_targetChanged ( oldTarget ) ; } var cursor = object . delegates_ ; while ( cursor ) { if ( cursor . delegate ) applyDelegateChanges ( cursor . delegate , oldRoot , oldTarget ) ; cursor = cursor . next ; } }
Apply changes for all delegate graph
Apply changes for all delegate graph