elasticsales/backbone.mousetrap — pull request #5 by jasoncrawford (2013-07-24 17:45:26+00:00)
Title: Don't let views remove other views' key bindings

This fixes the following bug:

1. View A binds 'x' to an event
2. View B binds 'x' to its own event, overwriting View A
3. View A unbinds all of its keyboard events (say, on remove())

In this case you would expect that View B would still have its event
binding, but it doesn't, because View A removes all bindings for 'x'.

This fix keeps track of which objects own which keys, and only unbinds
if another view hasn't already come along and stolen this event.

(Another way to fix this would be to allow multiple listeners for an
event, and simply remove an object from the list when it unbinds itself.
But the original semantics of Mousetrap are that there's only one
listener, and the last one to call bind overwrites any previous ones.)