File tree Expand file tree Collapse file tree 4 files changed +16
-4
lines changed Expand file tree Collapse file tree 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) {
3434 vm . __v_skip = true
3535 // effect scope
3636 vm . _scope = new EffectScope ( true /* detached */ )
37+ vm . _scope . _vm = true
3738 // merge options
3839 if ( options && options . _isComponent ) {
3940 // optimize internal component instantiation
Original file line number Diff line number Diff line change @@ -209,15 +209,13 @@ export function mountComponent(
209209 // we set this to vm._watcher inside the watcher's constructor
210210 // since the watcher's initial patch may call $forceUpdate (e.g. inside child
211211 // component's mounted hook), which relies on vm._watcher being already defined
212- vm . _scope . on ( )
213212 new Watcher (
214213 vm ,
215214 updateComponent ,
216215 noop ,
217216 watcherOptions ,
218217 true /* isRenderWatcher */
219218 )
220- vm . _scope . off ( )
221219 hydrating = false
222220
223221 // 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 {
7171 options ?: WatcherOptions | null ,
7272 isRenderWatcher ?: boolean
7373 ) {
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+ )
7584 if ( ( this . vm = vm ) && isRenderWatcher ) {
7685 vm . _watcher = this
7786 }
Original file line number Diff line number Diff line change @@ -27,10 +27,14 @@ export class EffectScope {
2727 * @internal
2828 */
2929 scopes : EffectScope [ ] | undefined
30+ /**
31+ * indicates this being a component root scope
32+ * @internal
33+ */
34+ _vm ?: boolean
3035 /**
3136 * track a child scope's index in its parent's scopes array for optimized
3237 * removal
33- * @internal
3438 */
3539 private index : number | undefined
3640
You can’t perform that action at this time.
0 commit comments