bind this in onreadystatechange call

Summary:
I ran into this problem that `this` is undefined in `onreadystatechange` function calls while using this github api library: https://github.com/michael/github/blob/master/github.js#L72

It seems that in the browser, the `onreadystatechange` function expects `this` to be bound. This example on the xhr spec website can be seen using `this` similarly: https://xhr.spec.whatwg.org/#the-getresponseheader()-method
Closes https://github.com/facebook/react-native/pull/5373

Reviewed By: svcscm

Differential Revision: D2838940

Pulled By: nicklockwood

fb-gh-sync-id: e42184887c7abb0af9c4358a5f33b8c97155624c
This commit is contained in:
Connor McEwen 2016-01-18 08:54:14 -08:00 коммит произвёл facebook-github-bot-2
Родитель 474b5e9b80
Коммит b8ff6212f8
1 изменённых файлов: 1 добавлений и 1 удалений

Просмотреть файл

@ -247,7 +247,7 @@ class XMLHttpRequestBase {
if (onreadystatechange) {
// We should send an event to handler, but since we don't process that
// event anywhere, let's leave it empty
onreadystatechange(null);
onreadystatechange.call(this, null);
}
if (newState === this.DONE && !this._aborted) {
this._sendLoad();