Reviewers: Ray Ryan,

Description:
CellTable#onBrowserEvent finds the TD element in which an event
occurred, and then assumes that the TD has a parent TR and TBODY. This
is normally a safe assumption because browsers only fire native events
on elements that are attached to the page, which means a TR and TBODY is
present. However, if a the user selects a new value in a select element
inside the table, a change and mouseup event both fire, even if the
table is refreshed on the change event.  In practice, if a user changes
a value onchange and refreshes the table, the mouseup event will fire on
the old TD, which is no longer connected to the table.  As a result...
this patch checks that both the TR and TBODY are not null.


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

Affected files:
  M user/src/com/google/gwt/user/cellview/client/CellTable.java


Index: user/src/com/google/gwt/user/cellview/client/CellTable.java
===================================================================
--- user/src/com/google/gwt/user/cellview/client/CellTable.java (revision 8382) +++ user/src/com/google/gwt/user/cellview/client/CellTable.java (working copy)
@@ -635,9 +635,22 @@
       return;
     }

+ // Determine if we are in the header, footer, or body. Its possible that + // the table has been refreshed before the current event fired (ex. change + // event refreshes before mouseup fires), so we need to check each parent
+    // element.
+    Element trElem = cell.getParentElement();
+    if (trElem == null) {
+      return;
+    }
+    TableRowElement tr = TableRowElement.as(trElem);
+    Element sectionElem = tr.getParentElement();
+    if (sectionElem == null) {
+      return;
+    }
+    TableSectionElement section = TableSectionElement.as(sectionElem);
+
     // Forward the event to the associated header, footer, or column.
-    TableRowElement tr = TableRowElement.as(cell.getParentElement());
- TableSectionElement section = TableSectionElement.as(tr.getParentElement());
     int col = cell.getCellIndex();
     if (section == thead) {
       Header<?> header = headers.get(col);


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

Reply via email to