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(zone.js): change EventTarget methods zone.js added optional #35954

Closed

Conversation

JiaLiPassion
Copy link
Contributor

@JiaLiPassion JiaLiPassion commented Mar 9, 2020

zone.js add 2 methods in EventTarget.prototype, but those methods only exists when user import zone.js and also enable EventTarget monkey patch.
If user

  1. Not importing zone.js and use noop zone when bootstrapping Angular app.
  2. Or disable monkey patching zone.js EventTarget patch by defining __Zone_disable_EventTarget = true.

Those methods will not be there.

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • angular.io application / infrastructure changes
  • Other... Please describe:

mhevery
mhevery approved these changes Mar 9, 2020
Copy link
Contributor

@mhevery mhevery left a comment

LGTM, please change the commit msg:

fix(zone.js): Make `EventTarget` methods optional in `zone.js` extension API

`zone.js` added `removeAllListeners` and `eventListeners` methods in `EventTarget.prototype`, but those methods only exists when user import `zone.js` and also enables `EventTarget` monkey patching.

If user:
1. Does not import `zone.js` and uses `noop` zone when bootstrapping Angular app. OR
2. Disable monkey patching of `EventTarget` patch by defining `__Zone_disable_EventTarget = true`.

Then `removeAllListeners` and `eventListeners`  methods will not be present.

@ngbot
Copy link

@ngbot ngbot bot commented Mar 9, 2020

I see that you just added the PR action: merge label, but the following checks are still failing:
    failure status "ci/angular: size" is failing
    failure status "ci/circleci: test_ivy_aot" is failing
    pending forbidden labels detected: PR action: cleanup
    pending status "google3" is pending
    pending missing required status "ci/circleci: publish_snapshot"

If you want your PR to be merged, it has to pass all the CI checks.

If you can't get the PR to a green state due to flakes or broken master, please try rebasing to master and/or restarting the CI job. If that fails and you believe that the issue is not due to your change, please contact the caretaker and ask for help.

…ion API

`zone.js` added `removeAllListeners` and `eventListeners` methods in `EventTarget.prototype`, but those methods only exists when user import `zone.js` and also enables `EventTarget` monkey patching.

If user:
1. Does not import `zone.js` and uses `noop` zone when bootstrapping Angular app. OR
2. Disable monkey patching of `EventTarget` patch by defining `__Zone_disable_EventTarget = true`.

Then `removeAllListeners` and `eventListeners`  methods will not be present.
@JiaLiPassion
Copy link
Contributor Author

@JiaLiPassion JiaLiPassion commented Mar 9, 2020

@mhevery , thank you for the review, I have updated the PR.

@matsko
Copy link
Contributor

@matsko matsko commented Mar 11, 2020

@AndrewKushnir
Copy link
Contributor

@AndrewKushnir AndrewKushnir commented Mar 16, 2020

FYI, changes in this PR were tested against g3 as a part of #36043, using Global TAP run, which was successful. Thank you.

@angular-automatic-lock-bot
Copy link

@angular-automatic-lock-bot angular-automatic-lock-bot bot commented Apr 16, 2020

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Apr 16, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

5 participants