fix(runtime-core): ensure watchers are always registered to correct instance owner (#2495)
close: #2381
This commit is contained in:
@@ -285,7 +285,7 @@ function doWatch(
|
||||
scheduler
|
||||
})
|
||||
|
||||
recordInstanceBoundEffect(runner)
|
||||
recordInstanceBoundEffect(runner, instance)
|
||||
|
||||
// initial run
|
||||
if (cb) {
|
||||
|
||||
@@ -786,9 +786,12 @@ export function createSetupContext(
|
||||
|
||||
// record effects created during a component's setup() so that they can be
|
||||
// stopped when the component unmounts
|
||||
export function recordInstanceBoundEffect(effect: ReactiveEffect) {
|
||||
if (currentInstance) {
|
||||
;(currentInstance.effects || (currentInstance.effects = [])).push(effect)
|
||||
export function recordInstanceBoundEffect(
|
||||
effect: ReactiveEffect,
|
||||
instance = currentInstance
|
||||
) {
|
||||
if (instance) {
|
||||
;(instance.effects || (instance.effects = [])).push(effect)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user