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

Commit

Permalink
fix($http): update httpBackend to use ActiveXObject on IE8 if necessary
Browse files Browse the repository at this point in the history
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
  • Loading branch information
jorgt authored and IgorMinar committed Feb 1, 2014
1 parent fd61e22 commit ef210e5
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
10 changes: 10 additions & 0 deletions docs/content/error/httpBackend/noxhr.ngdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
@ngdoc error
@name $httpBackend:noxhr
@fullName Unsupported XHR
@description

This error occurs in browsers that do not support XmlHttpRequest. AngularJS
supports Safari, Chrome, Firefox, Opera, IE8 and higher, and mobile browsers
(Android, Chrome Mobile, iOS Safari). To avoid this error, use an officially
supported browser.

17 changes: 11 additions & 6 deletions src/ng/httpBackend.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
'use strict';

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

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

/**
* @ngdoc object
Expand Down

0 comments on commit ef210e5

Please sign in to comment.