Reviewers: jgw,

Description:
Double clicking on a disabled input element results in a native NPE:
http://code.google.com/p/google-web-toolkit/issues/detail?id=4027

GWT fires a synthetic click event on double click in IE.  However, if an
input element is disabled, the srcElement of the event is some weird
node type that does not support the fireEvent method.


Fix:
====
We now check that fireEvent is defined before trying to fire the
synthetic click event.  This is consistent with other browsers that do
not fire click events on disabled input elements.

Testing:
=======
I manually verified that this patch fixes the problem in IE.  However,
this cannot be unit tested because programatically dispatching an event
on a disabled element actually works.  The double click must be done
using the mouse to trigger the bug.

Please review this at http://gwt-code-reviews.appspot.com/151804

Affected files:
  user/src/com/google/gwt/user/client/impl/DOMImplTrident.java


Index: user/src/com/google/gwt/user/client/impl/DOMImplTrident.java
===================================================================
--- user/src/com/google/gwt/user/client/impl/DOMImplTrident.java (revision 7605) +++ user/src/com/google/gwt/user/client/impl/DOMImplTrident.java (working copy)
@@ -142,7 +142,8 @@
@com.google.gwt.user.client.impl.DOMImplTrident::dispatchDblClickEvent = $entry(function() {
       var newEvent = $doc.createEventObject();
       // Synthesize a click event if one hasn't already been synthesized.
-      if ($wnd.event.returnValue == null) {
+      // Issue 4027: fireEvent is undefined on disabled input elements.
+ if ($wnd.event.returnValue == null && $wnd.event.srcElement.fireEvent) {
         $wnd.event.srcElement.fireEvent('onclick', newEvent);
       }
       if (this.__eventBits & 2) {


--
http://groups.google.com/group/Google-Web-Toolkit-Contributors

Reply via email to