Skip to content

Commit

Permalink
fix: check document instead of window to detect browser (#1833)
Browse files Browse the repository at this point in the history
  • Loading branch information
brc-dd committed Jan 21, 2023
1 parent 1553dbc commit 0f145cb
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/client/theme-default/composables/flyout.ts
@@ -1,4 +1,5 @@
import { type Ref, ref, watch, readonly, onUnmounted } from 'vue'
import { inBrowser } from '../../shared.js'

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

if (typeof window !== 'undefined') {
if (inBrowser) {
!active && activateFocusTracking()

listeners++
Expand Down
2 changes: 1 addition & 1 deletion src/shared/shared.ts
Expand Up @@ -20,7 +20,7 @@ export const APPEARANCE_KEY = 'vitepress-theme-appearance'
export const HASH_RE = /#.*$/
export const EXT_RE = /(index)?\.(md|html)$/

export const inBrowser = typeof window !== 'undefined'
export const inBrowser = typeof document !== 'undefined'

export const notFoundPageData: PageData = {
relativePath: '',
Expand Down

0 comments on commit 0f145cb

Please sign in to comment.