ArcBees / gwtquery

A jQuery clone for GWT, and much more.
MIT License
85 stars 38 forks source link

Bug in JsUtils.prop, when fetching an empty String it returns null #361

Open oheavy opened 8 years ago

oheavy commented 8 years ago

Hi,

I'm using GWT 2.7.0 and gwtquery 1.4.3 and I've encountered the following bug: When using public static <T> T prop(JavaScriptObject o, Object id) to retrieve a property that contains an empty String, it instead returns null. The following snippet of code can be used to replicate the problem:

JavaScriptObject jso = JavaScriptObject.createObject();
JsUtils.prop(jso, "property", "");
Object property = JsUtils.prop(jso, "property");

Here, I expected property to be an empty String, but instead it was null.

In order to get the empty String I had to use Properties, as can be seen in the following snippet of code:

JavaScriptObject jso = JavaScriptObject.createObject();
JsUtils.prop(jso, "property", "");
Properties propsJso = jso.cast();
String property = propsJso.getStr("property");

However, I expected the first snippet to return the same value.

Thanks, Luís