From 00182c88cb826f18900fd0e51eefe2c0fd1a7161 Mon Sep 17 00:00:00 2001 From: Guillaume Pannatier Date: Mon, 10 Nov 2014 11:53:28 +0100 Subject: [PATCH] fix($httpBackend): compare timeoutId with undefined in completeRequest httpBackend with ngMock browser.defer can never cancel the first deferredFn because the timeoutId returned by defer for the first fn is a zero value. Compare timeoutId with undefined fix this issue. --- src/ng/httpBackend.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/ng/httpBackend.js b/src/ng/httpBackend.js index 742d7aa86a85..5ba78b749932 100644 --- a/src/ng/httpBackend.js +++ b/src/ng/httpBackend.js @@ -126,7 +126,9 @@ function createHttpBackend($browser, createXhr, $browserDefer, callbacks, rawDoc function completeRequest(callback, status, response, headersString, statusText) { // cancel timeout and subsequent timeout promise resolution - timeoutId && $browserDefer.cancel(timeoutId); + if (timeoutId !== undefined) { + $browserDefer.cancel(timeoutId); + } jsonpDone = xhr = null; callback(status, response, headersString, statusText);