From 9b0a93995ec3bd9240abcf1c7f555677230a599a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fernando=20Fern=C3=A1ndez?= Date: Sat, 10 May 2025 13:13:29 +0000 Subject: [PATCH] feat(KeepAlive): pause deactivated components with freeze prop --- packages/runtime-core/src/components/KeepAlive.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/packages/runtime-core/src/components/KeepAlive.ts b/packages/runtime-core/src/components/KeepAlive.ts index f2b7bdf9738..6910de2b3e0 100644 --- a/packages/runtime-core/src/components/KeepAlive.ts +++ b/packages/runtime-core/src/components/KeepAlive.ts @@ -55,6 +55,7 @@ export interface KeepAliveProps { include?: MatchPattern exclude?: MatchPattern max?: number | string + freeze?: boolean | string } type CacheKey = PropertyKey | ConcreteComponent @@ -88,6 +89,7 @@ const KeepAliveImpl: ComponentOptions = { include: [String, RegExp, Array], exclude: [String, RegExp, Array], max: [String, Number], + freeze: [String, Boolean], }, setup(props: KeepAliveProps, { slots }: SetupContext) { @@ -160,6 +162,10 @@ const KeepAliveImpl: ComponentOptions = { } }, parentSuspense) + if (props.freeze) { + instance.scope.resume() + } + if (__DEV__ || __FEATURE_PROD_DEVTOOLS__) { // Update components tree devtoolsComponentAdded(instance) @@ -183,6 +189,10 @@ const KeepAliveImpl: ComponentOptions = { instance.isDeactivated = true }, parentSuspense) + if (props.freeze) { + instance.scope.resume() + } + if (__DEV__ || __FEATURE_PROD_DEVTOOLS__) { // Update components tree devtoolsComponentAdded(instance)