-
-
Notifications
You must be signed in to change notification settings - Fork 825
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
crmRouteBinder - Don't convert arrays to objects #12530
Conversation
(Standard links)
|
@totten I think you're the only one qualified to review this one. I'd like to get this merged before the 5.5 branch gets created so we can bundle in api4 sans-bugs. |
WRT to However, in terms of the logic, I have a doubt. Let's restate the basic logic as pseudocode:
Why bother with any cloning at all? Once we've setup the form, the user can interactively change the value of the field in the UI. Good for her. But if she makes a change, it should only apply to her view (and the active URL) -- it shouldn't propagate back to change the default value. You get that behavior automatically with primitive values (string/int), but for objects you have to clone. I think the same logic would apply to arrays that applies to objects -- but maybe OLD:
NEW (untested pseudocode):
|
Thanks for the review @totten - my goto function for this purpose is |
@totten I've pushed up that change. Much simpler! |
Actually, maybe https://code.angularjs.org/1.5.11/docs/api/ng/function/angular.copy would better... (EDIT) Hadn't seen your comment/push when posting that. I've got no opinion on whether _.cloneDeep or angular.copy is better. |
From reading the docs, they both do exactly the same thing, so either way I think we're good :) |
|
Overview
This fixes a subtle bug I encountered while writing the Api4 explorer.
Before
Arrays would be mangled because the function
_.isObject([])
will returntrue
.After
Arrays and objects are both treated nicely.