Skip to content

Commit

Permalink
fix(xhr): fix angular#1072, should set scheduled flag to target
Browse files Browse the repository at this point in the history
  • Loading branch information
JiaLiPassion committed Apr 10, 2018
1 parent 1ba8519 commit 7ac316a
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/browser/browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,9 @@ Zone.__load_patch('XHR', (global: any, Zone: ZoneType) => {
const SCHEDULED = 'scheduled';

function scheduleTask(task: Task) {
(XMLHttpRequest as any)[XHR_SCHEDULED] = false;
const data = <XHROptions>task.data;
const target = data.target;
target[XHR_SCHEDULED] = false;
// remove existing event listener
const listener = target[XHR_LISTENER];
if (!oriAddListener) {
Expand All @@ -143,7 +143,7 @@ Zone.__load_patch('XHR', (global: any, Zone: ZoneType) => {
if (target.readyState === target.DONE) {
// sometimes on some browsers XMLHttpRequest will fire onreadystatechange with
// readyState=4 multiple times, so we need to check task state here
if (!data.aborted && (XMLHttpRequest as any)[XHR_SCHEDULED] && task.state === SCHEDULED) {
if (!data.aborted && target[XHR_SCHEDULED] && task.state === SCHEDULED) {
task.invoke();
}
}
Expand All @@ -155,7 +155,7 @@ Zone.__load_patch('XHR', (global: any, Zone: ZoneType) => {
target[XHR_TASK] = task;
}
sendNative.apply(target, data.args);
(XMLHttpRequest as any)[XHR_SCHEDULED] = true;
target[XHR_SCHEDULED] = true;
return task;
}

Expand Down

0 comments on commit 7ac316a

Please sign in to comment.