]
Matous Jobanek commented on ARQGRA-496:
---------------------------------------
Hi [~vsevolodgolovanov]
Thank you for reporting this. If you have some working fix already for this issue, feel
free to send PR. We would be very thankful.
Our time and knowledge for maintaining this project are very limited, so we are glad for
any help.
JavaScript interface returns null instead of false for Booleans
---------------------------------------------------------------
Key: ARQGRA-496
URL:
https://issues.jboss.org/browse/ARQGRA-496
Project: Arquillian Graphene
Issue Type: Bug
Affects Versions: 2.1.0.Final
Reporter: Vsevolod Golovanov
{code}
@JavaScript(value = "MyObject")
public interface MyJsInterface {
Boolean getSomeValue();
}
{code}
If in js MyObject.someValue === false, then attempting to get the value via
Graphene's MyJsInterface will result in null getting returned, instead of false.
If you declare a primitive boolean return type, then null will get silently
'casted' to false, but that's not something I want either. I want to
distinguish the three states with Boolean. I want an exception for null with boolean.
{code:title=call.js/invokeInterface}
if (property && target[property]) {
return target[property];
}
{code}
There are 2 problems here.
# Instead of {{target\[property\]}} there should be an explicit
{{typeof(target\[property\]}) !== 'undefined')}} check (or {{property in target}},
if you want to distinguish the "property is defined, but its value is undefined"
case).
# When invokeInterface doesn't find neither getter, nor setter, nor method it quits
without returning or throwing anything. There should be some kind of explicit handling if
it can't find property/method at all.
The problem probably affects not only Booleans, but other types with falsey values too.