Log and skip init of synthetic keyboard events for IE11
We don't have a solution synthetic keyboard events in IE11
so this patch changes it to skip the initialization and log
the issue instead of throwing an exception.
Bug: issue 8463
Change-Id: I8230e542c7a6ec74418d62f6c4b3aadf41de59e1
Review-Link: https://gwt-review.googlesource.com/#/c/10202/
(cherry picked from commit d25051f64d60083d5e38f052f71ab49f96776963)
diff --git a/user/src/com/google/gwt/dom/client/DOMImplMozilla.java b/user/src/com/google/gwt/dom/client/DOMImplMozilla.java
index ab41f8d..d246e85 100644
--- a/user/src/com/google/gwt/dom/client/DOMImplMozilla.java
+++ b/user/src/com/google/gwt/dom/client/DOMImplMozilla.java
@@ -224,9 +224,17 @@
private native NativeEvent createKeyEventImpl(Document doc, String type,
boolean canBubble, boolean cancelable, boolean ctrlKey, boolean altKey,
boolean shiftKey, boolean metaKey, int keyCode, int charCode) /*-{
- var evt = doc.createEvent('KeyEvents');
- evt.initKeyEvent(type, canBubble, cancelable, null, ctrlKey, altKey,
- shiftKey, metaKey, keyCode, charCode);
+ var evt = doc.createEvent('KeyboardEvent');
+ if (evt.initKeyEvent) {
+ // Gecko
+ evt.initKeyEvent(type, canBubble, cancelable, null, ctrlKey, altKey,
+ shiftKey, metaKey, keyCode, charCode);
+ } else {
+ // This happens to be IE11+ as of today
+ if ($wnd.console) {
+ $wnd.console.error("Synthetic keyboard events are not supported in this browser");
+ }
+ }
return evt;
}-*/;