Skip to content

Commit

Permalink
codejedi365-fix-readystatechange-flow > improve codestyle
Browse files Browse the repository at this point in the history
### Rationale
Ensure logic is clear by avoiding empty return statements and
fall-through logic
  • Loading branch information
codejedi365 committed May 20, 2021
1 parent 1dcef93 commit 183eed9
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions lib/fake-xhr/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -513,8 +513,6 @@ function fakeXMLHttpRequestFor(globalScope) {
false,
this
);
var event, progress;

if (typeof this.onreadystatechange === "function") {
try {
this.onreadystatechange(readyStateChangeEvent);
Expand All @@ -523,7 +521,11 @@ function fakeXMLHttpRequestFor(globalScope) {
}
}

if (this.readyState === FakeXMLHttpRequest.DONE) {
if (this.readyState !== FakeXMLHttpRequest.DONE) {
this.dispatchEvent(readyStateChangeEvent);
} else {
var event, progress;

if (this.timedOut || this.aborted || this.status === 0) {
progress = { loaded: 0, total: 0 };
event =
Expand Down Expand Up @@ -557,10 +559,7 @@ function fakeXMLHttpRequestFor(globalScope) {
this.dispatchEvent(
new sinonEvent.ProgressEvent("loadend", progress, this)
);
return;
}

this.dispatchEvent(readyStateChangeEvent);
},

// Ref https://xhr.spec.whatwg.org/#the-setrequestheader()-method
Expand Down

0 comments on commit 183eed9

Please sign in to comment.