From 1904596e0c2330299e92f092bd7a6ceca8e97c30 Mon Sep 17 00:00:00 2001 From: Ali Mills Date: Fri, 1 Jun 2012 14:50:01 -0700 Subject: fix($timeout): allow calling $timeout.cancel() with undefined This is how it worked in rc9, before refactoring $defer into $timeout.--- src/ng/timeout.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/ng/timeout.js b/src/ng/timeout.js index ac92bf8c..5b51f85e 100644 --- a/src/ng/timeout.js +++ b/src/ng/timeout.js @@ -70,12 +70,12 @@ function $TimeoutProvider() { * Cancels a task associated with the `promise`. As a result of this the promise will be * resolved with a rejection. * - * @param {Promise} promise Promise returned by the `$timeout` function. + * @param {Promise=} promise Promise returned by the `$timeout` function. * @returns {boolean} Returns `true` if the task hasn't executed yet and was successfully * canceled. */ timeout.cancel = function(promise) { - if (promise.$$timeoutId in deferreds) { + if (promise && promise.$$timeoutId in deferreds) { deferreds[promise.$$timeoutId].reject('canceled'); return $browser.defer.cancel(promise.$$timeoutId); } -- cgit v1.2.3