]> source.dussan.org Git - gwtquery.git/commitdiff
Break all loops when a live event is handled and return false
authorManolo Carrasco <manolo@apache.org>
Thu, 7 Jun 2012 05:51:54 +0000 (05:51 +0000)
committerManolo Carrasco <manolo@apache.org>
Thu, 7 Jun 2012 05:51:54 +0000 (05:51 +0000)
gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/events/EventsListener.java

index 525671999ed889d8f611f8cb5af9cf921a9c9d81..5221b63423021a70a2fbc3f6f833e18e54423b0c 100644 (file)
@@ -175,6 +175,7 @@ public class EventsListener implements EventListener {
 
       boolean result = true;
       GqEvent gqEvent = GqEvent.create(event);
+      outerLoop:
       for (String cssSelector : realCurrentTargetBySelector.keys()) {
         JsObjectArray<BindFunction> 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;
               }
             }
           }