aboutsummaryrefslogtreecommitdiffstats
path: root/gwtquery-core
diff options
context:
space:
mode:
authorManuel Carrasco Moñino <manuel.carrasco.m@gmail.com>2012-12-10 10:24:01 +0100
committerManuel Carrasco Moñino <manuel.carrasco.m@gmail.com>2012-12-10 10:24:01 +0100
commitb915257904c9e782918841c39fe2762fd82ef06c (patch)
tree307e51e3811b119be1d8e2a9b41828d44ad8a584 /gwtquery-core
parent07263983873c3885b93238d6168aaaa74461c2e8 (diff)
downloadgwtquery-b915257904c9e782918841c39fe2762fd82ef06c.tar.gz
gwtquery-b915257904c9e782918841c39fe2762fd82ef06c.zip
Dont dispatch new added events when running the events dispatch loop. Fixes issue 152
Diffstat (limited to 'gwtquery-core')
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/events/EventsListener.java2
-rw-r--r--gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryEventsTestGwt.java18
2 files changed, 19 insertions, 1 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 38366b60..77abf267 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
@@ -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
diff --git a/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryEventsTestGwt.java b/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryEventsTestGwt.java
index fbc4c3e8..c5bdc5ac 100644
--- a/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryEventsTestGwt.java
+++ b/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryEventsTestGwt.java
@@ -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]);
+ }
}