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

Using _.union to combine arrays alters arrays with non unique values #130

Open
albertogasparin opened this issue Jan 2, 2015 · 0 comments

Comments

@albertogasparin
Copy link

Imagine you have a default like myArray : [].
Then, you initialize a model passing an initial value of myArray: [1,1,2,3].
The result of model.get('myArray') is not [1,1,2,3] but it is [1,2,3].

This issue is caused by this function:

combine = function(key) {
    return source[key] = _.union(destination[key], source[key]);
};

As a metter of fact, _.union returns all unique items inside the two arrays. So, if my destination[key] array is not unique the result will be wrong.

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