Skip to content

Commit c1b296c

Browse files
authored
fix(useScroll): evade edge case when window or document is Proxy (#3280)
1 parent a9c8b06 commit c1b296c

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

packages/core/useScroll/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,9 +170,9 @@ export function useScroll(
170170
return
171171

172172
const el = (
173-
target === window
173+
(target as Window).document
174174
? (target as Window).document.documentElement
175-
: target === window.document ? (target as Document).documentElement : target
175+
: (target as Document).documentElement ?? target
176176
) as HTMLElement
177177

178178
const { display, flexDirection } = getComputedStyle(el)
@@ -233,7 +233,7 @@ export function useScroll(
233233
return
234234

235235
const eventTarget = (
236-
e.target === window.document ? (e.target as Document).documentElement : e.target
236+
(e.target as Document).documentElement ?? e.target
237237
) as HTMLElement
238238

239239
setArrivedState(eventTarget)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy