Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: check document instead of window to detect browser #1833

Merged
merged 1 commit into from
Jan 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/client/theme-default/composables/flyout.ts
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
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