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

IE8 function createXhr(method) returns window.XMLHttpRequest(), is undefined #5677

Closed
jorgt opened this issue Jan 8, 2014 · 9 comments
Closed

Comments

@jorgt
Copy link
Contributor

jorgt commented Jan 8, 2014

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();
}

in IE8 on GET (and other) requests this returns a new window.XMLHttpRequest() which at least in my case throws a "typeerror: object expected" exception. Shouldn't this always return the ActiveXObject where < IE8 is concerned?

angularhttprequest

@ghost ghost assigned tbosch Jan 8, 2014
@tbosch
Copy link
Contributor

tbosch commented Jan 8, 2014

Most probably you are using quirks mode.
Please add a correct doctype to your doc, e.g. <!DOCTYPE html>

You can double check by opening the IE Dev Tools. Please comment if that's not your problem...

@tbosch tbosch closed this as completed Jan 8, 2014
@jorgt
Copy link
Contributor Author

jorgt commented Jan 8, 2014

I checked that and it's not the problem.

angularhttprequest

Edit: I actually ran it in quirks mode, but Angular warns about that apparently. Those logs do not show up normally.

@jorgt
Copy link
Contributor Author

jorgt commented Jan 8, 2014

It's my company's anal security policy. Closed indeed...

It does mean you can still check for the existence of window.XMLHttpRequest before you return it, which is a more sturdy way of checking it than just going by browser version.

angularhttprequest

@caitp
Copy link
Contributor

caitp commented Jan 8, 2014

Actually this doesn't seem unreasonable --- the updated createXHR stuff threw away a lot of stuff, and we might not be throwing the noxhr minerr anymore, or at least not under the same circumstances.

I'm not totally sure, but it's possible that this could be improved

@jorgt
Copy link
Contributor Author

jorgt commented Jan 8, 2014

As long as my companies policies do not change, I'll roll my own:

function createXhr(method) {
  // IE8 doesn't support PATCH method, but the ActiveX object does
  /* global ActiveXObject */
  return ((msie <= 8 || lowercase(method) === 'patch')|| isUndefined(window.XMLHttpRequest))
      ? new ActiveXObject('Microsoft.XMLHTTP')
      : new window.XMLHttpRequest();
}

@caitp
Copy link
Contributor

caitp commented Jan 8, 2014

@jorgt that particular code is going to instantiate an ActiveXObject regardless of the browser if the method is PATCH... That's not totally good.

But if you can improve this and turn it into a pull request which doesn't hurt evergreen browsers, it should be totally mergeable.

Once we have some better E2E test infrastructure, we can totally do a much better job of testing this stuff to make sure it actually works correctly.

jorgt added a commit to jorgt/angular.js that referenced this issue Jan 8, 2014
As per this issue: angular#5677

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.
@jorgt
Copy link
Contributor Author

jorgt commented Jan 8, 2014

My first pull requests, I hope that's ok. Thanks for catching the erroneous "||" I tried before.

@IgorMinar
Copy link
Contributor

@caitp I don't think that we'll ever have test for various IE security policy variations ;-) (just setting the expectations)

@caitp
Copy link
Contributor

caitp commented Jan 8, 2014

@IgorMinar what I meant was that we can be a bit more confident that changes to the httpBackend (for example) won't break evergreen browsers, or support IE browsers with "conventional" configurations, without testing manually. I think that is definitely something doable

jorgt added a commit to jorgt/angular.js that referenced this issue Jan 23, 2014
IgorMinar pushed a commit to IgorMinar/angular.js that referenced this issue Feb 1, 2014
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 angular#5677
Closes angular#5679
IgorMinar pushed a commit that referenced this issue Feb 1, 2014
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
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants