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 missing bind on mouse events listener #315

Merged
merged 4 commits into from Feb 26, 2020

Conversation

st-h
Copy link
Contributor

@st-h st-h commented Dec 1, 2019

This fixes missing binds for mouse event listeners as noticed in #304 . Tried to use the action helper, but this seems to only be available in recent ember versions, therefore using bind() to address this

this.element.addEventListener('mouseenter', this._mouseEnter);
this.element.addEventListener('mouseleave', this._mouseLeave);
this.set('_mouseEnterHandler', this._mouseEnter.bind(this));
this.set('_mouseLeaveHandler', this._mouseLeave.bind(this));
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we approach with 1 format here instead of having a this.set and set(this, ...) mixed in code? In fact it would be nicer to use Ember.setProperties(this, {}). Thoughts? @Turbo87 @sbatson5

Copy link
Contributor

Choose a reason for hiding this comment

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

since _mouseEnterHandler is never observed in the template you can also just use this._mouseEnter = this._mouseEnter.bind(this); to simplify it a little bit

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'd lean toward Ember.set since that's the convention used elsewhere.

Copy link
Contributor

Choose a reason for hiding this comment

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

@sbatson5 I'm confused: you 👍ed @Turbo87's suggestion and proposed another alternative. Which one would you like to be implemented?

Copy link
Collaborator

@sbatson5 sbatson5 Feb 18, 2020

Choose a reason for hiding this comment

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

@dcyriller Sorry for the confusion. I was 👍ing the suggestion that this.foo = x is possible rather than this.set('foo', x). However, given that that this repo is still using Ember.set('foo', x) everywhere, I would lean toward Ember.set.

@Turbo87
Copy link
Contributor

Turbo87 commented Feb 10, 2020

@sbatson5 @st-h is there anything we can do to move this forward?

@st-h
Copy link
Contributor Author

st-h commented Feb 10, 2020

@Turbo87 I am good with either approach, so I guess it's up to the maintainers do decide which to use

@sbatson5 sbatson5 merged commit dcbc95c into adopted-ember-addons:master Feb 26, 2020
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.

None yet

5 participants