Permalink
Browse files

Provides correct workaround for browsers which support ProgressEvent …

…but not the loadend event. Fixes bug introduced in 4f44c8f where SC.Request load (or error or abort) notifications would fail to fire in said browsers.
  • Loading branch information...
dcporter committed Feb 20, 2014
1 parent e436d94 commit 38640efc177184aaf8af12f3fe153e38dabdf6d5
Showing with 11 additions and 2 deletions.
  1. +11 −2 frameworks/ajax/system/response.js
@@ -552,7 +552,9 @@ SC.XHRResponse = SC.Response.extend(
if (rawRequest.onloadend || rawRequest.onloadend === null) {
SC.Event.add(rawRequest, 'loadend', this, this.finishRequest);
} else {
- SC.Event.add(rawRequest, 'readystatechange', this, this.finishRequest);
+ SC.Event.add(rawRequest, 'load', this, this.finishRequest);
+ SC.Event.add(rawRequest, 'error', this, this.finishRequest);
+ SC.Event.add(rawRequest, 'abort', this, this.finishRequest);
}
} else if (window.XMLHttpRequest && rawRequest.addEventListener) {
// XMLHttpRequest Level 1 + support for addEventListener (IE prior to version 9.0 lacks support for addEventListener)
@@ -661,7 +663,14 @@ SC.XHRResponse = SC.Response.extend(
if (window.ProgressEvent) {
// XMLHttpRequest Level 2
- SC.Event.remove(rawRequest, 'loadend', this, this.finishRequest);
+ // Some older webkit browsers with ProgressEvent don't support loadend.
+ if (rawRequest.onloadend || rawRequest.onloadend === null) {
+ SC.Event.remove(rawRequest, 'loadend', this, this.finishRequest);
+ } else {
+ SC.Event.remove(rawRequest, 'load', this, this.finishRequest);
+ SC.Event.remove(rawRequest, 'error', this, this.finishRequest);
+ SC.Event.remove(rawRequest, 'abort', this, this.finishRequest);
+ }
request = this.get('request');
listeners = request.get("listeners");

0 comments on commit 38640ef

Please sign in to comment.