-
-
Couldn't load subscription status.
- Fork 8.9k
fix(reactivity): fix WATCH_ARRAY v2 compat deep watching elements (fix #11872) #12236
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(reactivity): fix WATCH_ARRAY v2 compat deep watching elements (fix #11872) #12236
Conversation
Size ReportBundles
Usages
|
@vue/compiler-core
@vue/compiler-dom
@vue/compiler-sfc
@vue/compiler-ssr
@vue/reactivity
@vue/runtime-core
@vue/server-renderer
@vue/runtime-dom
@vue/shared
vue
@vue/compat
commit: |
|
Re-reading the |
|
Any updates on this? Currently we're having to resort to using |
|
I've just opened #13377, which builds on the work in this PR and fixes some further problems with |
|
Closing this in favor of #13377, which is definitely a more elegant implementation than my own |
close #11872
This makes a minor change that brings the
WATCH_ARRAYcompat behavior further in line with the Vue 2 behavior.Currently, watching an array with
WATCH_ARRAYcompat enabled will trigger the watch function on deep mutation of elements. This differs from the Vue 2 behavior, where the watch would trigger when array elements were added/removed/replaced, but not mutated.Changes:
isArray+isCompatEnabledcheck that was done before wrapping the getter, for a couple reasons:watchanyway, so this pre-check is redundant.options.deep = truebased on the initial value would lead to incorrect behavior if the initial value was an array but a future value wasn't.I couldn't find a way to test this change directly, however in an internal project an identical change using patch-package is working beautifully.
Also as a proof of concept that depth=1 would work I forked the reproduction example from #11872, disabled the
WATCH_ARRAYcompat, and set the watch to usedeep: 1: https://stackblitz.com/edit/vitejs-vite-qarbhv?file=src%2FApp.vue