javascript-kit
javascript-kit copied to clipboard
Error thrown for `getBoolean` when fragment does not yet exist.
getBoolean: function(name) {
var fragment = this.get(name);
return fragment.value && (fragment.value.toLowerCase() == 'yes' || fragment.value.toLowerCase() == 'on' || fragment.value.toLowerCase() == 'true');
},
Need to check if fragment is not null?
I had a "Select" type with yes/no, and I show default text of "no". User's then don't select "yes" assuming the value is "no" and then when I try to interpret the value I get the following error:
TypeError: Cannot read property 'value' of null
yes, we need to do a better job with the NPE in general (not just for getBoolean
). We're working on a newer version that will improve that.
Hi @erwan, any update on this? I vote it returns false
if not yes
, on
, true
— so including undefined
and null
. Thanks
@arnaudlewis I believe you worked on that?
@erwan no i did not but thanks for your message. I'll take a look asap @evvvritt
Also if you call api.getLink('text-url').url()
. It errors out if it doesn't exist, this shouldn't be the case in my opinion. You could use lodash get
method to solve it: https://lodash.com/docs/4.17.4#get. @erwan