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

Commit 509ec74

Browse files
committed
fix($httpBackend): prevent DOM err due to dereferencing .responseText
If responseType is defined and the request fails for one reason or another the .response property returned falsy value which caused dereferencing of .responseText. If the responseType was a blob or document then an error was thrown. To prevent this, I'm checking for responseType first and based on that dereferencing .response or .responseText. We need to keep on checking .responseText because that's the original XHR response api that is still needed for IE8 and 9. Closes #1922
1 parent d44ca19 commit 509ec74

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/ng/httpBackend.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,12 @@ function createHttpBackend($browser, XHR, $browserDefer, callbacks, rawDocument,
8787
}
8888
// end of the workaround.
8989

90-
completeRequest(callback, status || xhr.status, xhr.response || xhr.responseText,
91-
responseHeaders);
90+
// responseText is the old-school way of retrieving response (supported by IE8 & 9)
91+
// response and responseType properties were introduced in XHR Level2 spec (supported by IE10)
92+
completeRequest(callback,
93+
status || xhr.status,
94+
(xhr.responseType ? xhr.response : xhr.responseText),
95+
responseHeaders);
9296
}
9397
};
9498

0 commit comments

Comments
 (0)