Skip to content

Commit 0f145cb

Browse files
authoredJan 21, 2023
fix: check document instead of window to detect browser (#1833)
1 parent 1553dbc commit 0f145cb

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed
 

‎src/client/theme-default/composables/flyout.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { type Ref, ref, watch, readonly, onUnmounted } from 'vue'
2+
import { inBrowser } from '../../shared.js'
23

34
interface UseFlyoutOptions {
45
el: Ref<HTMLElement | undefined>
@@ -14,7 +15,7 @@ let listeners = 0
1415
export function useFlyout(options: UseFlyoutOptions) {
1516
const focus = ref(false)
1617

17-
if (typeof window !== 'undefined') {
18+
if (inBrowser) {
1819
!active && activateFocusTracking()
1920

2021
listeners++

‎src/shared/shared.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export const APPEARANCE_KEY = 'vitepress-theme-appearance'
2020
export const HASH_RE = /#.*$/
2121
export const EXT_RE = /(index)?\.(md|html)$/
2222

23-
export const inBrowser = typeof window !== 'undefined'
23+
export const inBrowser = typeof document !== 'undefined'
2424

2525
export const notFoundPageData: PageData = {
2626
relativePath: '',

0 commit comments

Comments
 (0)
Please sign in to comment.