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

fix(xhr): should invoke xhr task after onload is triggered #1055

Merged
merged 1 commit into from
Jun 18, 2018

Conversation

JiaLiPassion
Copy link
Collaborator

@JiaLiPassion JiaLiPassion commented Mar 23, 2018

fix angular/angular#20921
fix angular/angular#17192

currently zone.js patch xhr as a macroTask and after xhr.send, zone.js will add a readystatechange listener, when readystate=4, the macroTask will be invoked.

this logic work fine, but because xhr can also add onload or addEventListener('load', listener).
and the load event handler will run after readystatechange, so in the load event handler, the zone may have been stabled, and cause some issues. such as in angular/angular#20921, the chained http will trigger multiple zone.stable, and angular/angular#17192, the onload will run outside of fixture.whenStable.

So in this PR, I just make sure all onload is finished, then finally invoked the internal readystatechange task.

@JiaLiPassion JiaLiPassion force-pushed the xhr-onload branch 3 times, most recently from 93de36e to 4529684 Compare March 23, 2018 14:00
@JiaLiPassion JiaLiPassion changed the title WIP(xhr): should invoke xhr task after onload is triggered fix(xhr): should invoke xhr task after onload is triggered Mar 23, 2018
@quanterion
Copy link

Does it have a chance to be merged?

@mhevery mhevery merged commit 2aab9c8 into angular:master Jun 18, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
4 participants