Skip to content
This repository was archived by the owner on Dec 14, 2023. It is now read-only.
This repository was archived by the owner on Dec 14, 2023. It is now read-only.

Error thrown for getBoolean when fragment does not yet exist. #118

Open

Description

@ctrlplusb
  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

Activity

  1. erwan commented on Sep 29, 2016

    @erwan
    Contributor

    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.

  2. evvvritt commented on Apr 4, 2017

    @evvvritt

    Hi @erwan, any update on this? I vote it returns false if not yes, on, true — so including undefined and null. Thanks

  3. erwan commented on Apr 4, 2017

    @erwan
    Contributor

    @arnaudlewis I believe you worked on that?

  4. arnaudlewis commented on Apr 4, 2017

    @arnaudlewis
    Member

    @erwan no i did not but thanks for your message. I'll take a look asap @evvvritt

  5. sarunast commented on Apr 29, 2017

    @sarunast

    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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions