-
Notifications
You must be signed in to change notification settings - Fork 24
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
Fix case where multiple sections with same settings could modify shared configuration #48
Conversation
Nice test case. I'm wondering if the mergeDeep(cloneDeep()) could be optimized some how. Perhaps a special version of mergeDeep() where instead of just copy from edit: Or maybe this is where the cloneDeep() could be introduced: |
I agree this might be heavy handed, but it is only run at instantiation time as well. Interestingly this was the last place that assumed that In a related note: in a previous PR I optimized |
Changing something that might affect read sounds a little scary. I'm ok with mergeDeep(cloneDeep) if it is only a one-time cost at instantiation. |
👍 |
Updated the |
var newTo = to; | ||
if (safe) { | ||
newTo = {}; | ||
for (key in to) { |
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.
minor: move var key;
on line 14 earlier
- Add safe option to mergeDeep that prevents mutation from to object - Use safe option in non-hot code paths
bbefd32
to
24ab28e
Compare
🚢 |
See the test fixture where previously
"settings": ["lang:es"]
would modify the shared object withfoo: 3
causingycb.read({ lang: 'fr' })
to also resolve to3
even though it should be1
.@lingyan