Skip to content

Commit 5de2a41

Browse files
committed
fix(Avatar): window and document not defined
1 parent 65301f7 commit 5de2a41

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

packages/core/src/Avatar/AvatarFallback.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<script lang="ts">
22
import type { PrimitiveProps } from '@/Primitive'
3+
import { isClient } from '@vueuse/shared'
34
import { useForwardExpose } from '@/shared'
45
56
export interface AvatarFallbackProps extends PrimitiveProps {
@@ -23,7 +24,7 @@ useForwardExpose()
2324
const canRender = ref(props.delayMs === undefined)
2425
2526
watchEffect((onCleanup) => {
26-
if (props.delayMs) {
27+
if (props.delayMs && isClient) {
2728
const timerId = window.setTimeout(() => {
2829
canRender.value = true
2930
}, props.delayMs)

packages/core/src/Avatar/utils.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import type { ImgHTMLAttributes, Ref } from 'vue'
2+
import { isClient } from '@vueuse/shared'
23
import { computed, onMounted, onUnmounted, ref, watchEffect } from 'vue'
34

45
export type ImageLoadingStatus = 'idle' | 'loading' | 'loaded' | 'error'
@@ -23,7 +24,7 @@ export function useImageLoadingStatus(src: Ref<string>, { referrerPolicy, crossO
2324
if (!isMounted.value) {
2425
return null
2526
}
26-
if (!imageRef.value) {
27+
if (!imageRef.value && isClient) {
2728
imageRef.value = new window.Image()
2829
}
2930
return imageRef.value

0 commit comments

Comments
 (0)