-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
Avoid unwanted mutation to passed objects array to Group constructor #9151
Conversation
maybe a dumb unit test , an new group JEST file, that tests that given an array and doing a collection mutation on it, the original array is still intact, and that the 2 arrays do not pass the strict equality test. If we wanted to go full mutation protection we should clone the object, that would make the constructor async and i don't think we should do it at all. |
Done. Renamed changelog text and added a Jest test. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the comment can be simpler but it is not a deal breaker
Minor fix: since
Collection
mutates the_objects
array, this can cause really hard-to-debug bugs if the passed array of objects is used for other purposes as well by the application. To avoid any complication for the unaware developer, a copy should be made.