fix(runtime-core): instanceWatch should pass this.proxy to source as the first argument (#2753)

This commit is contained in:
edison
2021-02-09 15:00:32 +08:00
committed by GitHub
parent bd1240c127
commit ec8fd10cec
2 changed files with 27 additions and 3 deletions

View File

@@ -181,7 +181,9 @@ function doWatch(
} else if (isReactive(s)) {
return traverse(s)
} else if (isFunction(s)) {
return callWithErrorHandling(s, instance, ErrorCodes.WATCH_GETTER)
return callWithErrorHandling(s, instance, ErrorCodes.WATCH_GETTER, [
instance && (instance.proxy as any)
])
} else {
__DEV__ && warnInvalidSource(s)
}
@@ -190,7 +192,9 @@ function doWatch(
if (cb) {
// getter with cb
getter = () =>
callWithErrorHandling(source, instance, ErrorCodes.WATCH_GETTER)
callWithErrorHandling(source, instance, ErrorCodes.WATCH_GETTER, [
instance && (instance.proxy as any)
])
} else {
// no cb -> simple effect
getter = () => {