-
Notifications
You must be signed in to change notification settings - Fork 24.8k
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
bug(Zone.js): removing capture:true event listener breaks .on* event listeners #54581
Comments
We've also verified this issue exists on version |
Close angular#54581 Should not clear `onHandler` when remove capture event listeners.
@maxpatiiuk |
Close angular#54581 Should not clear `onHandler` when remove capture event listeners.
…angular#54602) Close angular#54581 Should not clear `onHandler` when remove capture event listeners. PR Close angular#54602
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Which @angular/* package(s) are the source of the bug?
zone.js
Is this a regression?
Yes
Description
The fix for #31643 introduced a bug
The following code
angular/packages/zone.js/lib/common/events.ts
Lines 580 to 583 in 8e65bdc
This happens because the code, when checking whether there are no more "capture click" tasks remaining (
existingTasks.length === 0
), forgets to check whether there are any "non-capture click" tasks presentThough, since on* listeners are non-capturing, maybe this code shouldn't run at all when capture:true events are removed?
Please provide a link to a minimal reproduction of the bug
https://stackblitz.com/edit/github-6rdbwr?file=src%2Fmain.ts
Please provide the exception or error you saw
Please provide the environment you discovered this bug in (run
ng version
)edit: affects Angular 17 too
Anything else?
I know that using on* is bad-practice, but it's coming from a library I rely on (for now). The capture:true events being set and removed is also from a library I rely on, so I can't easily remove these preconditions for the bug. As a workaround, I will use element ref to manually add/removeEventListener, but I am sure that there would be other places in my application affected by this bug
cc @JiaLiPassion
The text was updated successfully, but these errors were encountered: