-
-
Notifications
You must be signed in to change notification settings - Fork 116
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
Conversation
Merge branch 'master' into mouse-events
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)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
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 I am good with either approach, so I guess it's up to the maintainers do decide which to use |
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