Skip to content

Commit

Permalink
fix(XHRImpl): file:/// and IE9 bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
PatrickJS authored and vicb committed Jun 17, 2015
1 parent f93aae4 commit cd735c4
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions modules/angular2/src/render/xhr_impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,22 @@ export class XHRImpl extends XHR {
xhr.responseType = 'text';

xhr.onload = function() {
var status = xhr.status;
// responseText is the old-school way of retrieving response (supported by IE8 & 9)
// response/responseType properties were introduced in XHR Level2 spec (supported by IE10)
var response = ('response' in xhr) ? xhr.response : xhr.responseText;

// normalize IE9 bug (http://bugs.jquery.com/ticket/1450)
var status = xhr.status === 1223 ? 204 : xhr.status;

// fix status code when it is 0 (0 status is undocumented).
// Occurs when accessing file resources or on Android 4.1 stock browser
// while retrieving files from application cache.
if (status === 0) {
status = response ? 200 : 0;
}

if (200 <= status && status <= 300) {
completer.resolve(xhr.responseText);
completer.resolve(response);
} else {
completer.reject(`Failed to load ${url}`, null);
}
Expand Down

2 comments on commit cd735c4

@themihai
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does Angular2 need to support IE9??

@PatrickJS
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for anyone else that reads this please see issue #2584

Please sign in to comment.