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

Issue when unbinding an unknown listener #19

Open
vincent opened this issue Sep 15, 2013 · 3 comments
Open

Issue when unbinding an unknown listener #19

vincent opened this issue Sep 15, 2013 · 3 comments

Comments

@vincent
Copy link

vincent commented Sep 15, 2013

Hi, thanks for the lib

in the unbind function here https://github.com/jeromeetienne/microevent.js/blob/master/microevent.js#L22

the -1 result of indexOf should be tested separately, no ?
it looks like the last registered listener is randomly "spliced" when unbind is called with an unknown listener.

Am I missing something ?

@termi
Copy link

termi commented Jul 17, 2014

You are absolutely right. This is freaking wrong behavior. It should be like this:

var index = this._events[event].indexOf(fct);
if ( index != -1 ) {
    this._events[event].splice(index, 1);
}

@jeromeetienne
Copy link
Owner

good point, care to do a pull request

vincent added a commit to vincent/microevent.js that referenced this issue Aug 11, 2014
@vincent
Copy link
Author

vincent commented Aug 11, 2014

here you are #27

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

No branches or pull requests

3 participants