Skip to content

Commit cd735c4

Browse files
PatrickJSvicb
authored andcommitted
fix(XHRImpl): file:/// and IE9 bugs
1 parent f93aae4 commit cd735c4

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

modules/angular2/src/render/xhr_impl.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,22 @@ export class XHRImpl extends XHR {
1111
xhr.responseType = 'text';
1212

1313
xhr.onload = function() {
14-
var status = xhr.status;
14+
// responseText is the old-school way of retrieving response (supported by IE8 & 9)
15+
// response/responseType properties were introduced in XHR Level2 spec (supported by IE10)
16+
var response = ('response' in xhr) ? xhr.response : xhr.responseText;
17+
18+
// normalize IE9 bug (http://bugs.jquery.com/ticket/1450)
19+
var status = xhr.status === 1223 ? 204 : xhr.status;
20+
21+
// fix status code when it is 0 (0 status is undocumented).
22+
// Occurs when accessing file resources or on Android 4.1 stock browser
23+
// while retrieving files from application cache.
24+
if (status === 0) {
25+
status = response ? 200 : 0;
26+
}
27+
1528
if (200 <= status && status <= 300) {
16-
completer.resolve(xhr.responseText);
29+
completer.resolve(response);
1730
} else {
1831
completer.reject(`Failed to load ${url}`, null);
1932
}

0 commit comments

Comments
 (0)