Skip to content

Commit 48613bb

Browse files
authored
refactor(scheduler): simplify checkRecursiveUpdates (#11856)
1 parent f80d447 commit 48613bb

File tree

1 file changed

+18
-22
lines changed

1 file changed

+18
-22
lines changed

packages/runtime-core/src/scheduler.ts

+18-22
Original file line numberDiff line numberDiff line change
@@ -267,27 +267,23 @@ function flushJobs(seen?: CountMap) {
267267
}
268268

269269
function checkRecursiveUpdates(seen: CountMap, fn: SchedulerJob) {
270-
if (!seen.has(fn)) {
271-
seen.set(fn, 1)
272-
} else {
273-
const count = seen.get(fn)!
274-
if (count > RECURSION_LIMIT) {
275-
const instance = fn.i
276-
const componentName = instance && getComponentName(instance.type)
277-
handleError(
278-
`Maximum recursive updates exceeded${
279-
componentName ? ` in component <${componentName}>` : ``
280-
}. ` +
281-
`This means you have a reactive effect that is mutating its own ` +
282-
`dependencies and thus recursively triggering itself. Possible sources ` +
283-
`include component template, render function, updated hook or ` +
284-
`watcher source function.`,
285-
null,
286-
ErrorCodes.APP_ERROR_HANDLER,
287-
)
288-
return true
289-
} else {
290-
seen.set(fn, count + 1)
291-
}
270+
const count = seen.get(fn) || 0
271+
if (count > RECURSION_LIMIT) {
272+
const instance = fn.i
273+
const componentName = instance && getComponentName(instance.type)
274+
handleError(
275+
`Maximum recursive updates exceeded${
276+
componentName ? ` in component <${componentName}>` : ``
277+
}. ` +
278+
`This means you have a reactive effect that is mutating its own ` +
279+
`dependencies and thus recursively triggering itself. Possible sources ` +
280+
`include component template, render function, updated hook or ` +
281+
`watcher source function.`,
282+
null,
283+
ErrorCodes.APP_ERROR_HANDLER,
284+
)
285+
return true
292286
}
287+
seen.set(fn, count + 1)
288+
return false
293289
}

0 commit comments

Comments
 (0)