Revision: 8385
Author: [email protected]
Date: Fri Jul 16 07:18:14 2010
Log: 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.
Review at http://gwt-code-reviews.appspot.com/695801
Review by: [email protected]
http://code.google.com/p/google-web-toolkit/source/detail?r=8385
Modified:
/trunk/user/src/com/google/gwt/user/cellview/client/CellTable.java
=======================================
--- /trunk/user/src/com/google/gwt/user/cellview/client/CellTable.java Thu
Jul 15 03:48:34 2010
+++ /trunk/user/src/com/google/gwt/user/cellview/client/CellTable.java Fri
Jul 16 07:18:14 2010
@@ -634,10 +634,23 @@
if (cell == null) {
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