hij1nx/EventEmitter2 — pull request #48 by sergeyksv (2012-01-31 15:13:45+00:00)
Title: Making off and offAny correctly handle wildcard selectors

Hi,

We kill some time investigating why things like obj.once("*.some.event") didn't work as expected. In our case it was executed more than once.
Later we found that issues is caused by logic in .off function that return result from traversing of latest leaf which can be empty event if some matches happens.
I do belive that remove have to work simetrically to .on logic. So at least if I have something like obj.on("*.some.event, handler) the code obj.off("*.some.event, handler) should detach that handler.
In addition to that if I have obj.on("foo.some.event, handler), obj.on("bar.some.event, handler) the code obj.on("*.some.event, handler) should remove both (because both selectors match). The first is a must, the last might be questionable but I think this is how off should work.
We do the fix that remove listeners from all matched leafs. Added two test cases, all other test cases passed as well.
We do three commits, one to fix test cases on node 0.4.x (I believe there is not specific requirements of 0.6.x, we still use 0.4.x since it more stable). Another to add test cases that check what I desriber. Specifically check #9, which is almost the same as #8, but #8 work, #9 not (in existing code). And final comit with fixes. I believe they are safe and didn't break anything, only fix the logic