Skip to content
Open
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
5 changes: 5 additions & 0 deletions src/packages/barrage/barrage.taro.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,11 @@ const InternalBarrage: ForwardRefRenderFunction<
if (!loop && index.current >= list.length) {
return
}
if (
typeof document === 'undefined' ||
typeof document.createElement !== 'function'
)
return

const _index = loop ? index.current % list.length : index.current
const el = document.createElement(`View`)
Expand Down
5 changes: 5 additions & 0 deletions src/packages/imagepreview/imagepreview.taro.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,11 @@ export const ImagePreview: FunctionComponent<Partial<TaroImagePreviewProps>> = (
init()
}, [])
const init = () => {
if (
typeof document === 'undefined' ||
typeof document.addEventListener !== 'function'
)
return
document.addEventListener('touchmove', onTouchMove as any)
document.addEventListener('touchend', onTouchEnd)
document.addEventListener('touchcancel', onTouchEnd)
Expand Down
4 changes: 3 additions & 1 deletion src/packages/popover/popover.taro.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,9 @@ export const Popover: FunctionComponent<
nextTick(async () => {
const rect = targetId
? await getRectInMultiPlatform(
document.querySelector(`#${targetId}`),
typeof document !== 'undefined'
? document.querySelector(`#${targetId}`)
: null,
targetId
)
: await getRectInMultiPlatform(popoverRef.current, popoverId)
Expand Down
5 changes: 5 additions & 0 deletions src/packages/swipe/swipe.taro.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,11 @@ export const Swipe = forwardRef<
}))

useEffect(() => {
if (
typeof document === 'undefined' ||
typeof document.addEventListener !== 'function'
)
return
// 并没有生效
const handler: any = (event: { target: Node | null }) => {
const targets = [root]
Expand Down
Loading