-
Notifications
You must be signed in to change notification settings - Fork 421
Only attempt unbind when __bindEvents is defined #1780
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
Conversation
This error can and has served as a good warning that something is wrong. Are we sure we want to remove it? Sent from my iPhone
|
I can't imagine we'd want to throw that error for the case I outlined. What others exist? Can you think of some off hand? |
I'd want an error thrown for that case. Sent from my iPhone
|
Calling unbind without arguments is invalid. Calling unbind that doesn't actually unbind is invalid. I've never been a fan of how jQuery swallows errors. I don't think we should do it too. Sent from my iPhone
|
Maybe there's a better alternative to my use case then. How I can I safely remove all bindings from a compute, regardless of whether it is or isn't bound to already? |
Maybe is misunderstood what you are trying to do. Removing the error is different then making it possible to not pass an event handler and have all handlers removed. Sent from my iPhone
|
You're right. I assumed that calling I could swear I've confirmed this before. But now I'm not sure. I probably got this mixed up with how |
c34bb14
to
126e8fa
Compare
One slight clarification. Calling You can remove all of the bindings of a particular type by calling That said, doing so will still throw an error if there are no bindings at the time Also, test added. |
126e8fa
to
2fe8455
Compare
Looks good. @akagomez anyway you can resolve the merge conflicts, make sure travis passes, and merge this into master? |
2fe8455
to
13468fc
Compare
Rebased. Tests passing. Good to merge. |
Only attempt unbind when __bindEvents is defined
The confusion may be due to the fact that I opened the issue for the case I attributed that error to calling
This PR prevents an error from being thrown if Making |
An error is thrown if
unbind
is called on a compute that has no bindings.This PR addresses the issue by returning early when
__bindEvents
is falsy, as is done inevent.js
here: https://github.com/bitovi/canjs/blob/master/event/event.js#L196-L198Closes #1779