2
0
mirror of https://github.com/devbridge/jQuery-Autocomplete.git synced 2024-12-22 10:58:55 +00:00

update findBestHint function

solve the "Cannot read property 'toLowerCase' of undefined" issue with findBestHint function when  suggestion.value doesn't exist
This commit is contained in:
Gilles Migliori 2021-01-15 10:36:52 +01:00
parent 608d9efaa6
commit 9b98ccc7ef
3 changed files with 9 additions and 6 deletions

File diff suppressed because one or more lines are too long

View File

@ -1,6 +1,6 @@
{
"name": "devbridge-autocomplete",
"version": "1.4.11",
"version": "1.4.12",
"description": "Autocomplete provides suggestions while you type into the text field.",
"homepage": "https://github.com/devbridge/jQuery-Autocomplete",
"author": "Tomas Kirda (https://twitter.com/tkirda)",

View File

@ -761,9 +761,12 @@
}
$.each(that.suggestions, function (i, suggestion) {
var foundMatch = suggestion.value.toLowerCase().indexOf(value) === 0;
if (foundMatch) {
bestMatch = suggestion;
var foundMatch = false;
if (suggestion.value !== undefined) {
foundMatch = suggestion.value.toLowerCase().indexOf(value) === 0;
if (foundMatch) {
bestMatch = suggestion;
}
}
return !foundMatch;
});