@SuppressWarnings("unchecked")
public final <T> T get(Object id, Class<? extends T> clz) {
Object o = get(id);
- if (clz != null) {
+ if (o != null && clz != null) {
if (o instanceof Double) {
Double d = (Double)o;
if (clz == Float.class) o = d.floatValue();
*/
package com.google.gwt.query.client;
+import static com.google.gwt.query.client.GQuery.$;
+import static com.google.gwt.query.client.GQuery.$$;
+import static com.google.gwt.query.client.GQuery.document;
+import static com.google.gwt.query.client.GQuery.window;
+
import com.google.gwt.dom.client.Document;
import com.google.gwt.dom.client.Element;
import com.google.gwt.dom.client.InputElement;
import java.util.Comparator;
import java.util.List;
-import static com.google.gwt.query.client.GQuery.$;
-import static com.google.gwt.query.client.GQuery.$$;
-import static com.google.gwt.query.client.GQuery.document;
-import static com.google.gwt.query.client.GQuery.window;
-
/**
* Test class for testing gwtquery-core api.
*/
assertEquals("red", $(parent).css(CSS.BACKGROUND_COLOR, false));
}
+ public void testDataString() {
+ // put something in the cache for the element
+ $(e).data("initCache", "initCache");
+
+ assertNotNull($(e).data("initCache", String.class));
+
+ // returned the string "null" before the patch
+ assertNull($(e).data("nonExistingKey", String.class));
+ }
+
public void testData() {
assertEquals(null, $().data("whatever"));