File tree 4 files changed +16
-4
lines changed
4 files changed +16
-4
lines changed Original file line number Diff line number Diff line change @@ -34,6 +34,7 @@ export function initMixin(Vue: typeof Component) {
34
34
vm . __v_skip = true
35
35
// effect scope
36
36
vm . _scope = new EffectScope ( true /* detached */ )
37
+ vm . _scope . _vm = true
37
38
// merge options
38
39
if ( options && options . _isComponent ) {
39
40
// optimize internal component instantiation
Original file line number Diff line number Diff line change @@ -209,15 +209,13 @@ export function mountComponent(
209
209
// we set this to vm._watcher inside the watcher's constructor
210
210
// since the watcher's initial patch may call $forceUpdate (e.g. inside child
211
211
// component's mounted hook), which relies on vm._watcher being already defined
212
- vm . _scope . on ( )
213
212
new Watcher (
214
213
vm ,
215
214
updateComponent ,
216
215
noop ,
217
216
watcherOptions ,
218
217
true /* isRenderWatcher */
219
218
)
220
- vm . _scope . off ( )
221
219
hydrating = false
222
220
223
221
// flush buffer for flush: "pre" watchers queued in setup()
Original file line number Diff line number Diff line change @@ -71,7 +71,16 @@ export default class Watcher implements DepTarget {
71
71
options ?: WatcherOptions | null ,
72
72
isRenderWatcher ?: boolean
73
73
) {
74
- recordEffectScope ( this , activeEffectScope || ( vm ? vm . _scope : undefined ) )
74
+ recordEffectScope (
75
+ this ,
76
+ // if the active effect scope is manually created (not a component scope),
77
+ // prioritize it
78
+ activeEffectScope && ! activeEffectScope . _vm
79
+ ? activeEffectScope
80
+ : vm
81
+ ? vm . _scope
82
+ : undefined
83
+ )
75
84
if ( ( this . vm = vm ) && isRenderWatcher ) {
76
85
vm . _watcher = this
77
86
}
Original file line number Diff line number Diff line change @@ -27,10 +27,14 @@ export class EffectScope {
27
27
* @internal
28
28
*/
29
29
scopes : EffectScope [ ] | undefined
30
+ /**
31
+ * indicates this being a component root scope
32
+ * @internal
33
+ */
34
+ _vm ?: boolean
30
35
/**
31
36
* track a child scope's index in its parent's scopes array for optimized
32
37
* removal
33
- * @internal
34
38
*/
35
39
private index : number | undefined
36
40
You can’t perform that action at this time.
0 commit comments