Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

Commit

Permalink
fix(zone.bind): throw an error if arg is not a function
Browse files Browse the repository at this point in the history
  • Loading branch information
mhevery authored and btford committed Jun 18, 2015
1 parent 85dff6a commit ee4262a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ Zone.prototype = {
},

bind: function (fn, skipEnqueue) {
if (typeof fn !== 'function') {
throw new Error('Expecting function got: ' + fn);
}
skipEnqueue || this.enqueueTask(fn);
var zone = this.isRootZone() ? this : this.fork();
return function zoneBoundFn() {
Expand Down
7 changes: 7 additions & 0 deletions test/zone.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,13 @@ describe('Zone', function () {
});
});
});


it('should throw if argument is not a function', function () {
expect(function () {
zone.bind(11);
}).toThrowError('Expecting function got: 11');
});
});


Expand Down

0 comments on commit ee4262a

Please sign in to comment.