-
-
Notifications
You must be signed in to change notification settings - Fork 8.4k
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(vModel): skip value update in mounted hook if value was previously updated #12482
base: main
Are you sure you want to change the base?
Conversation
Size ReportBundles
Usages
|
@vue/compiler-core
@vue/compiler-dom
@vue/compiler-sfc
@vue/compiler-ssr
@vue/runtime-core
@vue/reactivity
@vue/runtime-dom
@vue/server-renderer
@vue/shared
vue
@vue/compat
commit: |
/ecosystem-ci run |
📝 Ran ecosystem CI: Open
|
To be honest I don't know what the best resolution is. This feels a bit like a hack/work-around: I think the intuition / expectation of Vue developers are:
Based on this, I'd say that if an update happens while the component is being mounted, then maybe one solution may be this: no |
If beforeUpdate or updated is not called, it might cause some edge cases, I think it should put the |
@edison1105 Maybe that would be a solution, too. |
Yes, that's what I meant above. |
close #12460
The root cause is that the component's
mounted
hook is executed asynchronously, while thebeforeUpdate
hook is executed synchronously. If an update occurs during the component's mounting, thebeforeUpdate
hook will execute beforemounted
. This also causes vModelText'sbeforeUpdate
to execute beforemounted
, resulting in the value set in thebeforeUpdate
hook being updated again in the mounted hook.onBeforeUpdate
of the component is executed beforeonMounted
beforeUpdate
of the directive is executed beforemounted
I'm not sure if this is the correct solution, but the impact should be minimal. Perhaps the correct approach is to ensure that the mounted hook always executes before the beforeUpdate hook.