From 072bb424d16e6faba243dcf1ab247494cbf8c9ee Mon Sep 17 00:00:00 2001 From: Stephen Blott Date: Fri, 2 Jan 2015 17:57:19 +0000 Subject: Modes; better constant naming. --- lib/handler_stack.coffee | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'lib') diff --git a/lib/handler_stack.coffee b/lib/handler_stack.coffee index 764461e7..d2d0672a 100644 --- a/lib/handler_stack.coffee +++ b/lib/handler_stack.coffee @@ -5,8 +5,14 @@ class HandlerStack constructor: -> @stack = [] @counter = 0 - @passDirectlyToPage = new Object() # Used only as a constant, distinct from any other value. - @eventConsumed = new Object() # Used only as a constant, distinct from any other value. + + # A handler should return this value to immediately discontinue bubbling and pass the event on to the + # underlying page. + @stopBubblingAndTrue = new Object() + + # A handler should return this value to indicate that the event has been consumed, and no further + # processing should take place. + @stopBubblingAndFalse = new Object() genId: -> @counter = ++@counter @@ -29,14 +35,8 @@ class HandlerStack if not passThrough DomUtils.suppressEvent(event) if @isChromeEvent event return false - # If the constant @passDirectlyToPage is returned, then discontinue further bubbling and pass the - # event through to the underlying page. The event is not suppresssed. - if passThrough == @passDirectlyToPage - return false - # If the constant @eventConsumed is returned, then discontinue further bubbling and - # return false. - if passThrough == @eventConsumed - return false + return true if passThrough == @stopBubblingAndTrue + return false if passThrough == @stopBubblingAndFalse true remove: (id = @currentId) -> -- cgit v1.2.3