diff --git a/lib/core.js b/lib/core.js index 24ed034ac..59070dc45 100644 --- a/lib/core.js +++ b/lib/core.js @@ -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() { diff --git a/test/zone.spec.js b/test/zone.spec.js index ffa39ff60..245f1a0d2 100644 --- a/test/zone.spec.js +++ b/test/zone.spec.js @@ -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'); + }); });