diff --git a/src/atom/binding-set.coffee b/src/atom/binding-set.coffee index 4ccae9b40..a123434be 100644 --- a/src/atom/binding-set.coffee +++ b/src/atom/binding-set.coffee @@ -16,10 +16,13 @@ class BindingSet constructor: (@selector, mapOrFunction) -> @specificity = Specificity(@selector) + @commandForEvent = @buildEventHandler(mapOrFunction) + + buildEventHandler: (mapOrFunction) -> if _.isFunction(mapOrFunction) - @commandForEvent = mapOrFunction + mapOrFunction else - @commandForEvent = (event) => + (event) => for pattern, command of mapOrFunction return command if @eventMatchesPattern(event, pattern) null