Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Search with 0 to match 0 does not find a match. #52

Open
Vaccano opened this issue Jan 13, 2018 · 1 comment
Open

Search with 0 to match 0 does not find a match. #52

Vaccano opened this issue Jan 13, 2018 · 1 comment

Comments

@Vaccano
Copy link

Vaccano commented Jan 13, 2018

If you have an item with the value of 1 in the list to search, it finds a match.

But if you have a value of 0 it is not matched on.

I found this when using selectize, which uses this library to perform the sorting. I had an id that was 0 and I could not get it to match on it. (Unfortunate because 0 is an important item in my list.)

@Vaccano
Copy link
Author

Vaccano commented Jan 13, 2018

I was able to fix this by modifying the source:

I changed the scoreValue subfunction's second and third lines to this:

if (value === null || typeof value === 'undefined') return 0;
value = String(value);

It was this:

if (value) return 0;
value = String(value || '');

If value was 0 then this failed. And the second check was not needed because of the previous one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant