const newProps = n2.props || EMPTY_OBJ
let vnodeHook: VNodeHook | undefined | null
+ // disable recurse in beforeUpdate hooks
+ parentComponent && toggleRecurse(parentComponent, false)
if ((vnodeHook = newProps.onVnodeBeforeUpdate)) {
invokeVNodeHook(vnodeHook, parentComponent, n2, n1)
}
if (dirs) {
invokeDirectiveHook(n2, n1, parentComponent, 'beforeUpdate')
}
+ parentComponent && toggleRecurse(parentComponent, true)
if (__DEV__ && isHmrUpdating) {
// HMR updated, force full diff
const { bm, m, parent } = instance
const isAsyncWrapperVNode = isAsyncWrapper(initialVNode)
- effect.allowRecurse = false
+ toggleRecurse(instance, false)
// beforeMount hook
if (bm) {
invokeArrayFns(bm)
) {
instance.emit('hook:beforeMount')
}
- effect.allowRecurse = true
+ toggleRecurse(instance, true)
if (el && hydrateNode) {
// vnode has adopted host node - perform hydration instead of mount.
}
// Disallow component effect recursion during pre-lifecycle hooks.
- effect.allowRecurse = false
-
+ toggleRecurse(instance, false)
if (next) {
next.el = vnode.el
updateComponentPreRender(instance, next, optimized)
) {
instance.emit('hook:beforeUpdate')
}
-
- effect.allowRecurse = true
+ toggleRecurse(instance, true)
// render
if (__DEV__) {
}
// create reactive effect for rendering
- const effect = new ReactiveEffect(
+ const effect = (instance.effect = new ReactiveEffect(
componentUpdateFn,
() => queueJob(instance.update),
instance.scope // track it in component's effect scope
- )
+ ))
const update = (instance.update = effect.run.bind(effect) as SchedulerJob)
update.id = instance.uid
// allowRecurse
// #1801, #2043 component render effects should allow recursive updates
- effect.allowRecurse = update.allowRecurse = true
+ toggleRecurse(instance, true)
if (__DEV__) {
effect.onTrack = instance.rtc
])
}
+function toggleRecurse(
+ { effect, update }: ComponentInternalInstance,
+ allowed: boolean
+) {
+ effect.allowRecurse = update.allowRecurse = allowed
+}
+
/**
* #1156
* When a component is HMR-enabled, we need to make sure that all static nodes