Skip to content

Null values in query data causes a null value error. #408

@weenchehawk

Description

@weenchehawk

If the result of a web query contains null data, for example as per nickname below;

{
 "status": true,
  "error": null,
  "data": {
    "user": [
      {
        "personid": 1,
        "familyname": "De-Flores",
        "firstname": "Nancy",
        "nickname": null,
        "birthlocation": "Somewhere Beautiful, Alabama",
      }
    ]
  }
}

A null value failure is encountered at jquery.typeahead.min.js:10:23495.

This seems to map to jquery.typeahead.js::1923

                        if (~[undefined, true].indexOf(groupFilter)) {
                            comparedDisplay = displayValue;
                            comparedDisplay = comparedDisplay.toString().toLowerCase();

                            if (this.options.accent) {
                                comparedDisplay = this.helper.removeAccent.call(
                                    this,
                                    comparedDisplay
                                );
                            }

Suggested fix is to check for null in the if ()

                        if (displayValue != null && ~[undefined, true].indexOf(groupFilter))
                        {
                            comparedDisplay = displayValue;

I patched my .min. with if(r != null && . . . and it seems to work.

Hardly a rigorous fix but there's little point in me digging about in the .js for a day - I'd still probably miss something subtle. Hope we can get a full fix soon.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions