HenrikJoreteg / wildemitter

A super lightweight EventEmitter similar to what comes in Node.js, but with a support for wildcard events '*'
MIT License
213 stars 21 forks source link

Fixed issue where removing event handler which wasn't added was removing all event's handlers except of the last one. #20

Closed konradkierus closed 5 years ago

konradkierus commented 5 years ago

@HenrikJoreteg I've encountered on a case in my code where handler was being removed before it was added. It took a while to track down the issue but in the end, it turned out if there are multiple handles attached and if we want to remove a handler which wasn't added (so indexOf would return -1) then all event handlers would be removed except of the last one in the array.

a = [1,2,3] i = a.indexOf(10) a.splice(i, 1) // result = a = [3]

HenrikJoreteg commented 5 years ago

published as 1.2.1, thanks!