getPropertyInt and getPropertyDouble return 0 for undefined property

9 views
Skip to first unread message

AJ

unread,
Jul 23, 2011, 3:25:24 PM7/23/11
to google-we...@googlegroups.com
Found in GWT Release 2.3

Encountered on Windows 7 : Chrome

The code for getPropertyInt and getPropertyDouble in the Element class is...

  public final native int getPropertyInt(String name) /*-{
     return parseInt(this[name]) || 0;
   }-*/;

  public final native double getPropertyDouble(String name) /*-{
     return parseFloat(this[name]) || 0.0;
   }-*/;

The result is that code can not determine if the value is truly zero, or if the property does not exist.

A method... isProperty(String name) ... would help to see if the property exists, but there isn't one.

Perhaps the methods should throw an exception?

Workaround if you have one: Don't use zero as a value.

Reply all
Reply to author
Forward
0 new messages