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 [1142] remaining mouseEnter/mouseLeave deprecations by adding eve… #1143

Merged

Conversation

fpauser
Copy link
Contributor

@fpauser fpauser commented Apr 2, 2020

…nt listeners

this.element.removeEventListener('mouseleave', this._mouseLeaveHandler);

this._mouseEnterHandler = undefined;
this._mouseLeaveHandler = undefined;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fpauser Why do we have to define a handler property to store the action and then clear it in will destroy ? Instead we can directly assign the actions to event listener and remove it in will destroy hook.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Its needed because bind() returns a new function bound to this with each call. To have removeEventListener remove our handler we have to give it the exact same handler function that was given to addEventHandler.

this.handleMouseEnter.bind(this) !== this.handleMouseEnter.bind(this)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Otherwise we'd produce leaks.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is a good insight. Thanks

@fpauser
Copy link
Contributor Author

fpauser commented Apr 16, 2020

Can we have a fresh release with the fix?

@miguelcobain miguelcobain merged commit c0fe0a7 into adopted-ember-addons:master May 9, 2020
@miguelcobain
Copy link
Collaborator

Thanks, @fpauser!
A new release is coming shortly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants