From dd361ef1f9f0ef32a3f921949d8c7d2bc07e5bdd Mon Sep 17 00:00:00 2001 From: Manolo Carrasco Date: Thu, 7 Jun 2012 05:51:54 +0000 Subject: [PATCH] Break all loops when a live event is handled and return false --- .../query/client/plugins/events/EventsListener.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/events/EventsListener.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/events/EventsListener.java index 52567199..5221b634 100644 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/events/EventsListener.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/events/EventsListener.java @@ -175,6 +175,7 @@ public class EventsListener implements EventListener { boolean result = true; GqEvent gqEvent = GqEvent.create(event); + outerLoop: for (String cssSelector : realCurrentTargetBySelector.keys()) { JsObjectArray bindFunctions = bindFunctionBySelector.get(cssSelector); for (int i = 0; bindFunctions != null && i < bindFunctions.length(); i++) { @@ -184,11 +185,10 @@ public class EventsListener implements EventListener { for (int j = 0; n != null && j < n.getLength(); j++) { Element element = n.getItem(i); gqEvent.setCurrentElementTarget(element); - boolean subResult = f.fire(gqEvent); - result &= subResult; - if (!subResult) { - // Event should not continue to be bubbled, break the second for - break; + result = f.fire(gqEvent); + if (!result) { + // Event should not continue because returning false, means to run it once + break outerLoop; } } } -- 2.39.5