mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-03-17 07:40:22 +00:00
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
This commit is contained in:
parent
d44ca19da7
commit
509ec745fd
1 changed files with 6 additions and 2 deletions
|
|
@ -87,8 +87,12 @@ function createHttpBackend($browser, XHR, $browserDefer, callbacks, rawDocument,
|
|||
}
|
||||
// end of the workaround.
|
||||
|
||||
completeRequest(callback, status || xhr.status, xhr.response || xhr.responseText,
|
||||
responseHeaders);
|
||||
// responseText is the old-school way of retrieving response (supported by IE8 & 9)
|
||||
// response and responseType properties were introduced in XHR Level2 spec (supported by IE10)
|
||||
completeRequest(callback,
|
||||
status || xhr.status,
|
||||
(xhr.responseType ? xhr.response : xhr.responseText),
|
||||
responseHeaders);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue