From: jdramaix Date: Thu, 10 Apr 2014 13:10:55 +0000 (+0200) Subject: Fix event bubbling for custom event for IE6-8. X-Git-Tag: gwtquery-project-1.4.3~36^2~2 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=163b15aa0ef6361484c462a6f363dbbd6800885e;p=gwtquery.git Fix event bubbling for custom event for IE6-8. --- diff --git a/gwtquery-core/pom.xml b/gwtquery-core/pom.xml index 31aede2d..1ef308f8 100644 --- a/gwtquery-core/pom.xml +++ b/gwtquery-core/pom.xml @@ -8,7 +8,7 @@ gwtquery jar - 1.4.1 + 1.4.2-SNAPSHOT Gwt Query Core API http://gquery.org diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/Events.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/Events.java index c89cf884..70928b02 100644 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/Events.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/Events.java @@ -17,7 +17,6 @@ import com.google.gwt.dom.client.Element; import com.google.gwt.dom.client.FormElement; import com.google.gwt.dom.client.NativeEvent; import com.google.gwt.dom.client.Node; -import com.google.gwt.event.dom.client.HasNativeEvent; import com.google.gwt.query.client.Function; import com.google.gwt.query.client.GQuery; import com.google.gwt.query.client.js.JsUtils; @@ -401,7 +400,7 @@ public class Events extends GQuery { // Ie6-8 don't dispatch bitless event if ((browser.ie6 || browser.ie8) && Event.getTypeInt(evt.getType()) == -1) { - EventsListener.getInstance(e).dispatchEvent(evt.cast()); + bubbleEventForIE(e, evt.cast()); } else { e.dispatchEvent(evt); } @@ -414,6 +413,25 @@ public class Events extends GQuery { } } + private void bubbleEventForIE(Element e, Event event) { + if (e == null || "html".equalsIgnoreCase(e.getTagName()) || isEventPropagationStopped(event)) { + return; + } + + EventsListener.getInstance(e).dispatchEvent(event); + + bubbleEventForIE(e.getParentElement(), event); + } + + /** + * Only valid for IE6-8 + * @param event + * @return + */ + private native boolean isEventPropagationStopped(Event event)/*-{ + return !!event.cancelBubble; + }-*/; + private void callHandlers(Element e, NativeEvent evt, Function... functions){ for (Function f : functions) { f.setEvent(Event.as(evt)); diff --git a/pom.xml b/pom.xml index ccf7fc60..c1b358dd 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ com.googlecode.gwtquery gwtquery-project pom - 1.4.1 + 1.4.2-SNAPSHOT Gwt Query Project http://gwtquery.com GwtQuery is a jQuery clone written in GWT.