From 0d0310d34e230115a0cd3389835a0fdd2109c66d Mon Sep 17 00:00:00 2001 From: neverland Date: Sat, 13 Feb 2021 20:57:06 +0800 Subject: [PATCH] fix(@vant/use): useRect should always return DOMRect (#8147) --- packages/vant-use/src/useRect/index.ts | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/packages/vant-use/src/useRect/index.ts b/packages/vant-use/src/useRect/index.ts index e02b96af4..01cb2f186 100644 --- a/packages/vant-use/src/useRect/index.ts +++ b/packages/vant-use/src/useRect/index.ts @@ -12,27 +12,12 @@ export const useRect = ( if (isWindow(element)) { const width = element.innerWidth; const height = element.innerHeight; - - return { - top: 0, - left: 0, - right: width, - bottom: height, - width, - height, - }; + return new DOMRect(0, 0, width, height); } if (element && element.getBoundingClientRect) { return element.getBoundingClientRect(); } - return { - top: 0, - left: 0, - right: 0, - bottom: 0, - width: 0, - height: 0, - }; + return new DOMRect(0, 0, 0, 0); };