]> source.dussan.org Git - gwtquery.git/commitdiff
Dont dispatch new added events when running the events dispatch loop. Fixes issue 152
authorManuel Carrasco Moñino <manuel.carrasco.m@gmail.com>
Mon, 10 Dec 2012 09:24:01 +0000 (10:24 +0100)
committerManuel Carrasco Moñino <manuel.carrasco.m@gmail.com>
Mon, 10 Dec 2012 09:24:01 +0000 (10:24 +0100)
gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/events/EventsListener.java
gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryEventsTestGwt.java

index 38366b60f7f08f79f7d9d70137e613c490bf75f6..77abf2679a2805768564d451cb847bc723b8be3f 100644 (file)
@@ -495,7 +495,7 @@ public class EventsListener implements EventListener {
     int etype = getTypeInt(event.getType());
     String originalEventType = GqEvent.getOriginalEventType(event);
 
-    for (int i = 0; i < elementEvents.length(); i++) {
+    for (int i = 0, l = elementEvents.length(); i < l; i++) {
       BindFunction listener = elementEvents.get(i);
       if (listener.hasEventType(etype)
           && (originalEventType == null || originalEventType
index fbc4c3e8cd41a8f7bc57e0dc0b4e724e980cb8f5..c5bdc5ac91a07f901190c3f9ef1daf213a25e5b2 100644 (file)
@@ -1223,5 +1223,23 @@ public class GQueryEventsTestGwt extends GWTTestCase {
     assertEquals("red", $("button").css("color", false));
     assertEquals("black", $("button").css("background-color", false));
   }
+  
+  public void testIssue152() {
+    $(e).html("<div class='mdiv'>");
+    final GQuery div = $(".mdiv", e); 
+    final int[] count = { 0 };
+    div.one(Event.ONCLICK, null, new Function() {
+      public void f() {
+        count[0]++;
+        div.one(Event.ONCLICK, null, new Function() {
+          public void f() {
+            fail();
+          }
+        });
+      };
+    });
 
+    div.click();
+    assertEquals(1, count[0]);
+  }
 }