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

Commit ef210e5

Browse files
jorgtIgorMinar
authored andcommitted
fix($http): update httpBackend to use ActiveXObject on IE8 if necessary
window.XMLHttpRequest is not always available in IE8 despite it not running in quirks mode, in which case Angular should be using the ActiveXObject instead. Just checking the browser version is taking too many shortcuts. Closes #5677 Closes #5679
1 parent fd61e22 commit ef210e5

File tree

2 files changed

+21
-6
lines changed

2 files changed

+21
-6
lines changed
+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
@ngdoc error
2+
@name $httpBackend:noxhr
3+
@fullName Unsupported XHR
4+
@description
5+
6+
This error occurs in browsers that do not support XmlHttpRequest. AngularJS
7+
supports Safari, Chrome, Firefox, Opera, IE8 and higher, and mobile browsers
8+
(Android, Chrome Mobile, iOS Safari). To avoid this error, use an officially
9+
supported browser.
10+

src/ng/httpBackend.js

+11-6
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
11
'use strict';
22

33
function createXhr(method) {
4-
// IE8 doesn't support PATCH method, but the ActiveX object does
5-
/* global ActiveXObject */
6-
return (msie <= 8 && lowercase(method) === 'patch')
7-
? new ActiveXObject('Microsoft.XMLHTTP')
8-
: new window.XMLHttpRequest();
9-
}
4+
//if IE and the method is not RFC2616 compliant, or if XMLHttpRequest
5+
//is not available, try getting an ActiveXObject. Otherwise, use XMLHttpRequest
6+
//if it is available
7+
if (msie <= 8 && (!method.match(/^(get|post|head|put|delete|options)$/i) ||
8+
!window.XMLHttpRequest)) {
9+
return new ActiveXObject("Microsoft.XMLHTTP");
10+
} else if (window.XMLHttpRequest) {
11+
return new window.XMLHttpRequest();
12+
}
1013

14+
throw minErr('$httpBackend')('noxhr', "This browser does not support XMLHttpRequest.");
15+
}
1116

1217
/**
1318
* @ngdoc object

0 commit comments

Comments
 (0)