fix(reactivity): ensure computed is invalidated before other effects
fix #5720
This commit is contained in:
@@ -348,16 +348,31 @@ export function triggerEffects(
|
||||
debuggerEventExtraInfo?: DebuggerEventExtraInfo
|
||||
) {
|
||||
// spread into array for stabilization
|
||||
for (const effect of isArray(dep) ? dep : [...dep]) {
|
||||
if (effect !== activeEffect || effect.allowRecurse) {
|
||||
if (__DEV__ && effect.onTrigger) {
|
||||
effect.onTrigger(extend({ effect }, debuggerEventExtraInfo))
|
||||
}
|
||||
if (effect.scheduler) {
|
||||
effect.scheduler()
|
||||
} else {
|
||||
effect.run()
|
||||
}
|
||||
const effects = isArray(dep) ? dep : [...dep]
|
||||
for (const effect of effects) {
|
||||
if (effect.computed) {
|
||||
triggerEffect(effect, debuggerEventExtraInfo)
|
||||
}
|
||||
}
|
||||
for (const effect of effects) {
|
||||
if (!effect.computed) {
|
||||
triggerEffect(effect, debuggerEventExtraInfo)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function triggerEffect(
|
||||
effect: ReactiveEffect,
|
||||
debuggerEventExtraInfo?: DebuggerEventExtraInfo
|
||||
) {
|
||||
if (effect !== activeEffect || effect.allowRecurse) {
|
||||
if (__DEV__ && effect.onTrigger) {
|
||||
effect.onTrigger(extend({ effect }, debuggerEventExtraInfo))
|
||||
}
|
||||
if (effect.scheduler) {
|
||||
effect.scheduler()
|
||||
} else {
|
||||
effect.run()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user