canjs / can-zone

A context for tracking asynchronous activity in JavaScript applications.
https://v4.canjs.com/doc/can-zone.html
MIT License
92 stars 4 forks source link

Wrapped event listeners cannot be removed #144

Closed matthewp closed 7 years ago

matthewp commented 7 years ago

can-zone wraps event listeners through addEventListener so that the handlers will run within the zone. If someone is to call removeEventListener, it will not be removed because a different (wrapped) function is the one that was actually registered.

matthewp commented 7 years ago

@justinbmeyer pointed out that this won't work if the handler is used multiple times.

I think this can be fixed by not wrapping a handler that has already been wrapped (having one wrapped version for each handler function).