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

Commit ee4262a

Browse files
mheverybtford
authored andcommitted
fix(zone.bind): throw an error if arg is not a function
1 parent 85dff6a commit ee4262a

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

lib/core.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ Zone.prototype = {
5858
},
5959

6060
bind: function (fn, skipEnqueue) {
61+
if (typeof fn !== 'function') {
62+
throw new Error('Expecting function got: ' + fn);
63+
}
6164
skipEnqueue || this.enqueueTask(fn);
6265
var zone = this.isRootZone() ? this : this.fork();
6366
return function zoneBoundFn() {

test/zone.spec.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,13 @@ describe('Zone', function () {
163163
});
164164
});
165165
});
166+
167+
168+
it('should throw if argument is not a function', function () {
169+
expect(function () {
170+
zone.bind(11);
171+
}).toThrowError('Expecting function got: 11');
172+
});
166173
});
167174

168175

0 commit comments

Comments
 (0)