This repository was archived by the owner on Feb 26, 2024. It is now read-only.
fix(patch): fix #708, modify the canPatchDescriptor logic when browser has no onreadystatechange#711
Merged
mhevery merged 1 commit intoangular:masterfrom Apr 21, 2017
Merged
Conversation
DaveMBush
reviewed
Apr 1, 2017
| return result; | ||
| // and if XMLHttpRequest.prototype.onreadystatechange is undefined, | ||
| // we should set a real desc instead a fake one | ||
| if (xhrDesc) { |
There was a problem hiding this comment.
It would probably make sense to just immediately return false if xhrDesc is falsy...
if (!xhrDesc) return;
this reduces nesting
Collaborator
Author
There was a problem hiding this comment.
@DaveMBush , the function canPatchDescriptor will see whether zone.js can patch global object, if return false, zone.js will not patch DOM,XHR, so everything will not in zone. So we have to pick up a global object to try to patch and see the result.
DaveMBush
approved these changes
Apr 2, 2017
| return result; | ||
| // and if XMLHttpRequest.prototype.onreadystatechange is undefined, | ||
| // we should set a real desc instead a fake one | ||
| if (xhrDesc) { |
mhevery
approved these changes
Apr 10, 2017
Contributor
|
could you rebase so that we can merge it in? |
… browser don't provide onreadystatechange
Collaborator
Author
|
@mhevery , I have rebased the PR, please review. |
|
great! @JiaLiPassion I need this for tests with jest+jsdom. For now i'm using a patch with your changes |
mhevery
approved these changes
Apr 21, 2017
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix #708,
in jsdom, XMLHttpRequest has no onreadystatechange,
in zone.js canPatchDescriptor logic, zone.js use a fake onreadystatechange descriptor which only have a getter, and XMLHttpRequest will use this one, and prevent set onreadystatechange property.
so we need to use a workable onreadystatechange descriptor in this case.