Skip to content

Commit

Permalink
Merge pull request #75 from natural-affinity/fix-event-context
Browse files Browse the repository at this point in the history
fix: event callback context
  • Loading branch information
AidasK committed Jan 31, 2015
2 parents f9fbbb2 + bf51175 commit 513eaa3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/flow.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@
if (this.events.hasOwnProperty(event)) {
each(this.events[event], function (callback) {
preventDefault = callback.apply(this, args.slice(1)) === false || preventDefault;
});
}, this);
}
if (event != 'catchall') {
args.unshift('catchAll');
Expand Down
11 changes: 10 additions & 1 deletion test/eventsSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,15 @@ describe('events', function() {
expect(valid).toBeTruthy();
});

it('should have a context of flow instance', function() {
var context = null;
flow.on('test', function () {
context = this;
});
flow.fire('test');
expect(context).toEqual(flow);
});

it('should pass some arguments', function() {
var valid = false;
var argumentOne = 123;
Expand Down Expand Up @@ -101,4 +110,4 @@ describe('events', function() {
expect(event).not.toHaveBeenCalled();
});
});
});
});

0 comments on commit 513eaa3

Please sign in to comment.