aboutsummaryrefslogtreecommitdiffstats
path: root/lib/handler_stack.coffee
diff options
context:
space:
mode:
Diffstat (limited to 'lib/handler_stack.coffee')
-rw-r--r--lib/handler_stack.coffee12
1 files changed, 9 insertions, 3 deletions
diff --git a/lib/handler_stack.coffee b/lib/handler_stack.coffee
index 4d186341..718bee9d 100644
--- a/lib/handler_stack.coffee
+++ b/lib/handler_stack.coffee
@@ -14,11 +14,17 @@ class HandlerStack
# processing should take place.
@stopBubblingAndFalse = new Object()
- # Adds a handler to the stack. Returns a unique ID for that handler that can be used to remove it later.
+ # Adds a handler to the top of the stack. Returns a unique ID for that handler that can be used to remove it
+ # later.
push: (handler) ->
- handler.id = ++@counter
@stack.push handler
- handler.id
+ handler.id = ++@counter
+
+ # Adds a handler to the bottom of the stack. Returns a unique ID for that handler that can be used to remove
+ # it later.
+ unshift: (handler) ->
+ @stack.unshift handler
+ handler.id = ++@counter
# Called whenever we receive a key or other event. Each individual handler has the option to stop the
# event's propagation by returning a falsy value, or stop bubbling by returning @stopBubblingAndFalse or