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

Bug when empty value in select where select elements are count from 0. #1049

Open
kstalega opened this issue Sep 28, 2017 · 1 comment
Open
Assignees

Comments

@kstalega
Copy link

Hi,

I think that I found bug in your code. To start with, I have select field with data-source set like this:

data-source="[{value: 0, text: 'Pan'}, {value: 1, text: 'Pani'}]"

and when this fields is empty it says that I've select option called 'Pan'. I tried to debug your code and I found that in http://cdnjs.cloudflare.com/ajax/libs/x-editable/1.5.0/bootstrap3-editable/js/bootstrap-editable.js at line 790 there is comparision with double =. See:
if(value == itemValue) { result.push(o); }

In this case value is "", and itemValue = 0, so "" == 0 => true. I think that there should be tripple ===, and it will return false as it should be.

What do you think? And besides, thank you very much for this very great pice of code!

@kstalega
Copy link
Author

In my investigation I've changed:

if(value == itemValue) {
    result.push(o); 
}

to

if(String(value) === String(itemValue)) {
     result.push(o); 
}

And in my case it works as expect, but I need make more tests. What do you think about that?

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

No branches or pull requests

2 participants