From 21da3fcafbb29540788037dbcdbdce79ad14e650 Mon Sep 17 00:00:00 2001 From: Stephen Blott Date: Wed, 30 Mar 2016 13:07:05 +0100 Subject: Rename handlerStack constants. Problems: - The meanings of some of the Mode/handlerStack constant names is far from obvious. - The same thing is named different things in different places. This changes various constant names such that: - the names used in the handler stack and in the modes are the same. - ditto vis-a-vis DomUtils. Also, break out the core of the handler stacks' `bubbleEvent` method into a switch statements. This makes it more obvious that the cases are mutually exclusive. --- tests/unit_tests/handler_stack_test.coffee | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'tests') diff --git a/tests/unit_tests/handler_stack_test.coffee b/tests/unit_tests/handler_stack_test.coffee index 629fc3ed..7b62af07 100644 --- a/tests/unit_tests/handler_stack_test.coffee +++ b/tests/unit_tests/handler_stack_test.coffee @@ -5,6 +5,7 @@ context "handlerStack", setup -> stub global, "DomUtils", {} stub DomUtils, "suppressEvent", -> + stub DomUtils, "suppressPropagation", -> @handlerStack = new HandlerStack @handler1Called = false @handler2Called = false @@ -23,16 +24,16 @@ context "handlerStack", assert.isTrue @handler2Called assert.isFalse @handler1Called - should "terminate bubbling on stopBubblingAndTrue, and be true", -> + should "terminate bubbling on passEventToPage, and be true", -> @handlerStack.push { keydown: => @handler1Called = true } - @handlerStack.push { keydown: => @handler2Called = true; @handlerStack.stopBubblingAndTrue } + @handlerStack.push { keydown: => @handler2Called = true; @handlerStack.passEventToPage } assert.isTrue @handlerStack.bubbleEvent 'keydown', {} assert.isTrue @handler2Called assert.isFalse @handler1Called - should "terminate bubbling on stopBubblingAndTrue, and be false", -> + should "terminate bubbling on passEventToPage, and be false", -> @handlerStack.push { keydown: => @handler1Called = true } - @handlerStack.push { keydown: => @handler2Called = true; @handlerStack.stopBubblingAndFalse } + @handlerStack.push { keydown: => @handler2Called = true; @handlerStack.suppressPropagation } assert.isFalse @handlerStack.bubbleEvent 'keydown', {} assert.isTrue @handler2Called assert.isFalse @handler1Called -- cgit v1.2.3