diff options
author | jdramaix <julien.dramaix@gmail.com> | 2014-04-10 15:10:55 +0200 |
---|---|---|
committer | jdramaix <julien.dramaix@gmail.com> | 2014-04-10 15:10:55 +0200 |
commit | 163b15aa0ef6361484c462a6f363dbbd6800885e (patch) | |
tree | 3b547e737a5724bf06f08636fd6c6dd09b7d9c36 /gwtquery-core | |
parent | bae2adda4ccdd08f2251e09394b85aebdf213b37 (diff) | |
download | gwtquery-163b15aa0ef6361484c462a6f363dbbd6800885e.tar.gz gwtquery-163b15aa0ef6361484c462a6f363dbbd6800885e.zip |
Fix event bubbling for custom event for IE6-8.
Diffstat (limited to 'gwtquery-core')
-rw-r--r-- | gwtquery-core/pom.xml | 2 | ||||
-rw-r--r-- | gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/Events.java | 22 |
2 files changed, 21 insertions, 3 deletions
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 @@ <artifactId>gwtquery</artifactId> <packaging>jar</packaging> - <version>1.4.1</version> + <version>1.4.2-SNAPSHOT</version> <name>Gwt Query Core API</name> <url>http://gquery.org</url> <dependencies> 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.<Event>cast()); + bubbleEventForIE(e, evt.<Event>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)); |