Skip to content
This repository was 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
mhevery merged 1 commit into
angular:masterfrom
JiaLiPassion:xhr-onload
Jun 18, 2018
Merged

fix(xhr): should invoke xhr task after onload is triggered#1055
mhevery merged 1 commit into
angular:masterfrom
JiaLiPassion:xhr-onload

Conversation

@JiaLiPassion

@JiaLiPassionJiaLiPassion commented Mar 23, 2018

Copy link
Copy Markdown
Collaborator

fixangular/angular#20921
fixangular/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
JiaLiPassionforce-pushed the xhr-onload branch 3 times, most recently from 93de36e to 4529684CompareMarch 23, 2018 14:00
@JiaLiPassionJiaLiPassion changed the title WIP(xhr): should invoke xhr task after onload is triggeredfix(xhr): should invoke xhr task after onload is triggeredMar 23, 2018
@quanterion

Copy link
Copy Markdown

Does it have a chance to be merged?

@mhevery
mhevery merged commit 2aab9c8 into angular:masterJun 18, 2018
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

4 participants

@JiaLiPassion@quanterion@mhevery@googlebot