aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/client/js/JsCache.java2
-rw-r--r--gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryCoreTestGwt.java20
2 files changed, 16 insertions, 6 deletions
diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/js/JsCache.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/js/JsCache.java
index f10d998b..71d3d3c0 100644
--- a/gwtquery-core/src/main/java/com/google/gwt/query/client/js/JsCache.java
+++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/js/JsCache.java
@@ -67,7 +67,7 @@ public class JsCache extends JavaScriptObject {
@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();
diff --git a/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryCoreTestGwt.java b/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryCoreTestGwt.java
index f5a5d157..f4a4d963 100644
--- a/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryCoreTestGwt.java
+++ b/gwtquery-core/src/test/java/com/google/gwt/query/client/GQueryCoreTestGwt.java
@@ -15,6 +15,11 @@
*/
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;
@@ -50,11 +55,6 @@ import java.util.Collections;
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.
*/
@@ -1557,6 +1557,16 @@ public class GQueryCoreTestGwt extends GWTTestCase {
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"));