diff --git a/package.json b/package.json index 082aea87..6bf59d24 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "rc-util", - "version": "5.13.2", + "version": "5.13.3", "description": "Common Utils For React Component", "keywords": [ "react", diff --git a/src/getScrollBarSize.tsx b/src/getScrollBarSize.tsx index 12a142f3..af597f78 100644 --- a/src/getScrollBarSize.tsx +++ b/src/getScrollBarSize.tsx @@ -54,9 +54,13 @@ export function getTargetScrollBarSize(target: HTMLElement) { return { width: 0, height: 0 }; } - const { width, height } = getComputedStyle(target, '::-webkit-scrollbar'); - return { - width: ensureSize(width), - height: ensureSize(height), - }; + try { + const { width, height } = getComputedStyle(target, '::-webkit-scrollbar'); + return { + width: ensureSize(width), + height: ensureSize(height), + }; + } catch (e) { + return { width: 0, height: 0 }; + } }