mirror of
https://gitee.com/vuejs/vue.git
synced 2024-12-03 12:38:24 +08:00
fix: ensure render watcher of manually created instance is correctly tracked in owner scope
fix #12701
This commit is contained in:
parent
4b37b568c7
commit
bd89ce53a9
@ -209,6 +209,7 @@ export function mountComponent(
|
|||||||
// we set this to vm._watcher inside the watcher's constructor
|
// we set this to vm._watcher inside the watcher's constructor
|
||||||
// since the watcher's initial patch may call $forceUpdate (e.g. inside child
|
// since the watcher's initial patch may call $forceUpdate (e.g. inside child
|
||||||
// component's mounted hook), which relies on vm._watcher being already defined
|
// component's mounted hook), which relies on vm._watcher being already defined
|
||||||
|
vm._scope.on()
|
||||||
new Watcher(
|
new Watcher(
|
||||||
vm,
|
vm,
|
||||||
updateComponent,
|
updateComponent,
|
||||||
@ -216,6 +217,7 @@ export function mountComponent(
|
|||||||
watcherOptions,
|
watcherOptions,
|
||||||
true /* isRenderWatcher */
|
true /* isRenderWatcher */
|
||||||
)
|
)
|
||||||
|
vm._scope.off()
|
||||||
hydrating = false
|
hydrating = false
|
||||||
|
|
||||||
// flush buffer for flush: "pre" watchers queued in setup()
|
// flush buffer for flush: "pre" watchers queued in setup()
|
||||||
|
@ -72,10 +72,8 @@ export default class Watcher implements DepTarget {
|
|||||||
isRenderWatcher?: boolean
|
isRenderWatcher?: boolean
|
||||||
) {
|
) {
|
||||||
recordEffectScope(this, activeEffectScope || (vm ? vm._scope : undefined))
|
recordEffectScope(this, activeEffectScope || (vm ? vm._scope : undefined))
|
||||||
if ((this.vm = vm)) {
|
if ((this.vm = vm) && isRenderWatcher) {
|
||||||
if (isRenderWatcher) {
|
vm._watcher = this
|
||||||
vm._watcher = this
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// options
|
// options
|
||||||
if (options) {
|
if (options) {
|
||||||
|
Loading…
Reference in New Issue
Block a user