Skip to content

Commit df8785e

Browse files
committed
Change response type before open() will cause InvalidStateError in IE11.
The error is documented here: https://connect.microsoft.com/IE/feedback/details/795580/ie11-xmlhttprequest-incorrectly-throws-invalidstateerror-when-setting-responsetype
1 parent 4000ba6 commit df8785e

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/CommentProvider.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,6 @@ var CommentProvider = (function () {
4848
uri += argsArray.join('&');
4949
}
5050

51-
xhr.responseType = typeof responseType === "string" ?
52-
responseType : "";
5351
xhr.onload = function () {
5452
if (this.status >= 200 && this.status < 300) {
5553
resolve(this.response);
@@ -63,6 +61,13 @@ var CommentProvider = (function () {
6361
};
6462

6563
xhr.open(method, uri);
64+
65+
// Change response type before open() will cause InvalidStateError in IE11.
66+
// The error is documented here:
67+
// https://connect.microsoft.com/IE/feedback/details/795580/ie11-xmlhttprequest-incorrectly-throws-invalidstateerror-when-setting-responsetype
68+
xhr.responseType = typeof responseType === "string" ?
69+
responseType : "";
70+
6671
if (typeof body !== 'undefined') {
6772
xhr.send(body);
6873
} else {

0 commit comments

Comments
 (0)