Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

Commit

Permalink
fix(xhr): fix #657, sometimes xhr will fire onreadystatechange with d…
Browse files Browse the repository at this point in the history
…one twice (#658)
  • Loading branch information
JiaLiPassion authored and mhevery committed Mar 7, 2017
1 parent 84459f1 commit 36c0899
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/browser/browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,9 @@ function patchXHR(window: any) {
}
const newListener = data.target[XHR_LISTENER] = () => {
if (data.target.readyState === data.target.DONE) {
if (!data.aborted && self[XHR_SCHEDULED]) {
// sometimes on some browsers XMLHttpRequest will fire onreadystatechange with
// readyState=4 multiple times, so we need to check task state here
if (!data.aborted && self[XHR_SCHEDULED] && task.state === 'scheduled') {
task.invoke();
}
}
Expand Down

0 comments on commit 36c0899

Please sign in to comment.