From c87250329232dcc4be705ad038d41e1309106838 Mon Sep 17 00:00:00 2001 From: jdramaix Date: Fri, 29 Nov 2013 00:38:43 +0100 Subject: [PATCH] fix ie8 custom event --- .../java/com/google/gwt/query/Query.gwt.xml | 9 +++++++ .../gwt/query/client/plugins/Events.java | 25 ++++++++++++++++++- 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/Query.gwt.xml b/gwtquery-core/src/main/java/com/google/gwt/query/Query.gwt.xml index a902fd99..e12b298e 100644 --- a/gwtquery-core/src/main/java/com/google/gwt/query/Query.gwt.xml +++ b/gwtquery-core/src/main/java/com/google/gwt/query/Query.gwt.xml @@ -144,6 +144,15 @@ + + + + + + + + + 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 94d1ab8d..897807f9 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 @@ -13,6 +13,7 @@ */ package com.google.gwt.query.client.plugins; +import com.google.gwt.core.client.GWT; import com.google.gwt.dom.client.Element; import com.google.gwt.dom.client.FormElement; import com.google.gwt.dom.client.NativeEvent; @@ -36,6 +37,8 @@ public class Events extends GQuery { } }); + private static final EventDispatcher EVENT_DISPATCHER = GWT.create(EventDispatcher.class); + /** * Don't apply events on text and comment nodes !! */ @@ -377,7 +380,9 @@ public class Events extends GQuery { for (Element e : elements()) { if (isEventCapable(e)) { $(e).data(EventsListener.EVENT_DATA, datas); - e.dispatchEvent(evt); + + EVENT_DISPATCHER.dispatch(e, evt); + if (!JsUtils.isDefaultPrevented(evt)) { callHandlers(e, evt, funcs); } @@ -393,4 +398,22 @@ public class Events extends GQuery { } } + static class EventDispatcher { + public void dispatch(Element e, NativeEvent evt) { + e.dispatchEvent(evt); + } + } + + @SuppressWarnings("unused") + static class EventDispatcherTrident extends EventDispatcher { + public void dispatch(Element e, NativeEvent evt) { + // bitless event ? + if (Event.getTypeInt(evt.getType()) != -1) { + super.dispatch(e, evt); + } else { + EventsListener.getInstance(e).dispatchEvent(evt.cast()); + } + } + } + } -- 2.39.5