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

Commit 36c0899

Browse files
JiaLiPassionmhevery
authored andcommitted
fix(xhr): fix #657, sometimes xhr will fire onreadystatechange with done twice (#658)
1 parent 84459f1 commit 36c0899

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

Diff for: lib/browser/browser.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,9 @@ function patchXHR(window: any) {
7373
}
7474
const newListener = data.target[XHR_LISTENER] = () => {
7575
if (data.target.readyState === data.target.DONE) {
76-
if (!data.aborted && self[XHR_SCHEDULED]) {
76+
// sometimes on some browsers XMLHttpRequest will fire onreadystatechange with
77+
// readyState=4 multiple times, so we need to check task state here
78+
if (!data.aborted && self[XHR_SCHEDULED] && task.state === 'scheduled') {
7779
task.invoke();
7880
}
7981
}

0 commit comments

Comments
 (0)