-
-
Notifications
You must be signed in to change notification settings - Fork 336
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: messages deepCopy
mutates src
arguments
#1947
fix: messages deepCopy
mutates src
arguments
#1947
Conversation
@intlify/core
@intlify/devtools-types
@intlify/core-base
@intlify/message-compiler
@intlify/shared
petite-vue-i18n
vue-i18n
@intlify/vue-i18n-core
commit: |
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.
Looks good to me!
Thank you!
I'm curious what the impact of this change is on performance since previously the objects assigned by reference were not looped over by key. |
Yeah, performance is certainly a concern, and I need to look at the cost of |
Somewhat related to performance and object checks (but not really related to this PR), I feel like #1379 should be reverted. The change was made to support Safari 10 which is not receiving security updates (Apple doesn't issue EOL dates), the original code seems to work fine for Vue core https://github.com/vuejs/core/blob/main/packages/shared/src/general.ts#L74-L75 and is likely more performant as well. |
Let's do it! |
9f3bb87
to
05b2353
Compare
I tried bench testing the change and it looks like it does impact performance but not excessively so, it's worth the trade-off. The way I tested it is not pretty so I pushed it to a separate branch, you can check out the changes and results in this PR BobbieGoede#5, I'm assuming we don't want to add a bench like this. |
Thanks! |
* fix: messages `deepCopy` mutates `src` arguments * fix: `deepCopy` should never merge arrays
* fix: messages `deepCopy` mutates `src` arguments * fix: `deepCopy` should never merge arrays
Important
This has not been thoroughly tested but should demonstrate the issue with
deepCopy
Currently during
deepCopy
if a key is unset, it will be assigned to the value of thesrc[key]
, this is an issue for objects as they will be assigned by reference, meaning following calls todeepCopy
will assign properties on these objects.So far a simple solution seems to be to set the property value to an empty object/array, this ensures both
src[key]
anddes[key]
are objects meaningdeepCopy
will merge these as such instead of direct assignment.I've had this saved in a git stash for some time so it has been a while since debugging this issue, I'm opening this PR so I won't forget about it again 😅
nuxt-modules/i18n#3089
nuxt-modules/i18n#2803