From ef822ded7ae342dd972b51c87877868cc7c0cb31 Mon Sep 17 00:00:00 2001 From: btea <2356281422@qq.com> Date: Fri, 4 Oct 2024 21:59:47 +0800 Subject: [PATCH] fix(hooks): [lockscreen] compatible with document non-existence (#18445) --- packages/hooks/use-lockscreen/index.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/hooks/use-lockscreen/index.ts b/packages/hooks/use-lockscreen/index.ts index fc378c287e..e36d8dd0fb 100644 --- a/packages/hooks/use-lockscreen/index.ts +++ b/packages/hooks/use-lockscreen/index.ts @@ -48,6 +48,9 @@ export const useLockscreen = ( const cleanup = () => { setTimeout(() => { + // When the test case is running, the context environment simulated by jsdom may have been destroyed, + // and the document does not exist at this time. + if (typeof document === 'undefined') return removeClass(document?.body, hiddenCls.value) if (withoutHiddenClass && document) { document.body.style.width = bodyWidth