-
-
Notifications
You must be signed in to change notification settings - Fork 8.5k
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
base: main
Are you sure you want to change the base?
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 |
close #11872
This makes a minor change that brings the
WATCH_ARRAY
compat behavior further in line with the Vue 2 behavior.Currently, watching an array with
WATCH_ARRAY
compat 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
+isCompatEnabled
check that was done before wrapping the getter, for a couple reasons:watch
anyway, so this pre-check is redundant.options.deep = true
based 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_ARRAY
compat, and set the watch to usedeep: 1
: https://stackblitz.com/edit/vitejs-vite-qarbhv?file=src%2FApp.vue