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 of optimizedKeys #218

Open
WindieChai opened this issue Oct 31, 2016 · 0 comments
Open

bug of optimizedKeys #218

WindieChai opened this issue Oct 31, 2016 · 0 comments

Comments

@WindieChai
Copy link

I'm trying to use ko.mapping to map a mix-typed array, then I found the result is very weird.
For example, following code:

ko.mapping.fromJS([1,2,3,'3'])()

Will get:

["3", 2, undefined × 1, "3"]

I just spent a little time on this issue and I found it is caused by the optimizedKeys determination starting from line 580 of knockout.mapping.js.
Just say, both string '3' and integer 3 will be used as key of a object (so there will be only one property with key '3'); then this key will be used to determine the index of the member; one of the members will get null for its index, so it use 0 by default and the correct position of that member will be undefined.

Currently I convert my array to an object array to avoid this issue.

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