Skip to content

Commit 67e8503

Browse files
committed
Merge pull request #112 from thorn0/master
Add events `error` and `abort`
2 parents 79232b5 + 94a27f1 commit 67e8503

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

lib/XMLHttpRequest.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -510,11 +510,12 @@ exports.XMLHttpRequest = function() {
510510
* Called when an error is encountered to deal with it.
511511
*/
512512
this.handleError = function(error) {
513-
this.status = 503;
513+
this.status = 0;
514514
this.statusText = error;
515515
this.responseText = error.stack;
516516
errorFlag = true;
517517
setState(this.DONE);
518+
this.dispatchEvent('error');
518519
};
519520

520521
/**
@@ -527,6 +528,7 @@ exports.XMLHttpRequest = function() {
527528
}
528529

529530
headers = defaultHeaders;
531+
this.status = 0;
530532
this.responseText = "";
531533
this.responseXML = "";
532534

@@ -539,6 +541,7 @@ exports.XMLHttpRequest = function() {
539541
setState(this.DONE);
540542
}
541543
this.readyState = this.UNSENT;
544+
this.dispatchEvent('abort');
542545
};
543546

544547
/**

0 commit comments

Comments
 (0)