Skip to content
Open
Changes from 1 commit
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
7 changes: 4 additions & 3 deletions src/getScrollBarSize.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ type ExtendCSSStyleDeclaration = CSSStyleDeclaration & {

let cached: ScrollBarSize;

function measureScrollbarSize(ele?: HTMLElement): ScrollBarSize {
function measureScrollbarSize(ele?: HTMLElement, csp?: { nonce?: string }): ScrollBarSize {
const randomId = `rc-scrollbar-measure-${Math.random()
.toString(36)
.substring(7)}`;
Expand Down Expand Up @@ -53,6 +53,7 @@ ${widthStyle}
${heightStyle}
}`,
randomId,
{ csp },
);
} catch (e) {
// Can't wrap, just log error
Expand Down Expand Up @@ -98,7 +99,7 @@ export default function getScrollBarSize(fresh?: boolean): number {
return cached.width;
}

export function getTargetScrollBarSize(target: HTMLElement) {
export function getTargetScrollBarSize(target: HTMLElement, csp?: { nonce?: string }) {
if (
typeof document === 'undefined' ||
!target ||
Expand All @@ -107,5 +108,5 @@ export function getTargetScrollBarSize(target: HTMLElement) {
return { width: 0, height: 0 };
}

return measureScrollbarSize(target);
return measureScrollbarSize(target, csp);
}