Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(Observable/Ajax): mount properties to origin readystatechange fn #2025

Merged
merged 5 commits into from
Oct 24, 2016

Conversation

Brooooooklyn
Copy link
Contributor

Description:
xhr.onreadystatechange property may be monkey patched by other library such as zone.js.
It would cause AjaxObservable could not find subscriber, progressSubscriber and request property on xhr.onreadystatechange.

it's a simple example here: http://plnkr.co/edit/oX1v8tTjTog1T57Z0JnI?p=preview

@coveralls
Copy link

Coverage Status

Coverage remained the same at 97.039% when pulling 00fc6b1 on Brooooooklyn:issue/ajax into 1bee98a on ReactiveX:master.

@Brooooooklyn Brooooooklyn force-pushed the issue/ajax branch 2 times, most recently from 72b778e to 4f2f376 Compare October 11, 2016 13:00
@coveralls
Copy link

Coverage Status

Coverage remained the same at 97.039% when pulling 4f2f376 on Brooooooklyn:issue/ajax into 1bee98a on ReactiveX:master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.03%) to 97.009% when pulling 3466354 on Brooooooklyn:issue/ajax into 1bee98a on ReactiveX:master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.03%) to 97.009% when pulling 3466354 on Brooooooklyn:issue/ajax into 1bee98a on ReactiveX:master.

@benlesh
Copy link
Member

benlesh commented Oct 11, 2016

@Brooooooklyn ... I'm struggling to understand the issue. I think I get it... but can you create a test case as part of this PR that definitively shows the issue this is trying to correct? You don't need to use zones, maybe just monkey patch the handler or something?

It seems if there's a problem like this, the alternative solution would be to use the addEventHandler means of registering handlers.

@jayphelps
Copy link
Member

@Blesh Indeed the issue is that zone.js does not respect the identity of the function you assign to the event callbacks. It wraps the function here so a new function created internally is the one you actually receive when we xhr.onreadystatechange.something = 123 etc.

IMO is solution is acceptable and effectively the same we'd need to do if we used xhr.addEventListener -- that is, we need to assign the function to a local scope var first, then use that local scope var to assign the props, independently of setting up the listener logic.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.2%) to 97.283% when pulling 5920621 on Brooooooklyn:issue/ajax into 1bee98a on ReactiveX:master.

@Brooooooklyn
Copy link
Contributor Author

@Blesh I've added some test in a separate commit, could you please review it.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.2%) to 97.284% when pulling 807cb7b on Brooooooklyn:issue/ajax into 5460e77 on ReactiveX:master.

@benlesh
Copy link
Member

benlesh commented Oct 19, 2016

Oh. I understand. Not sure why it wasn't sinking in the first time I looked at it.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.2%) to 97.284% when pulling 0101c52 on Brooooooklyn:issue/ajax into ece1b89 on ReactiveX:master.

@coveralls
Copy link

coveralls commented Oct 24, 2016

Coverage Status

Coverage increased (+0.2%) to 97.284% when pulling 0101c52 on Brooooooklyn:issue/ajax into ece1b89 on ReactiveX:master.

@jayphelps
Copy link
Member

LGTM

@jayphelps jayphelps merged commit 76a9abb into ReactiveX:master Oct 24, 2016
@lock
Copy link

lock bot commented Jun 6, 2018

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Jun 6, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants