Skip to content

Commit 39b9b65

Browse files
author
Simon Tran
committed
fix: guard against empty ResizeObserver size arrays
prevents TypeError when `contentBoxSize` or `borderBoxSize` arrays are empty in certain browser implementation or edge cases.
1 parent 836039f commit 39b9b65

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/internal/container-queries/use-resize-observer.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,10 @@ export function useResizeObserver(elementRef: ElementReference, onObserve: (entr
7474
function convertResizeObserverEntry(entry: ResizeObserverEntry): ContainerQueryEntry {
7575
return {
7676
target: entry.target,
77-
contentBoxWidth: entry.contentBoxSize[0].inlineSize,
78-
contentBoxHeight: entry.contentBoxSize[0].blockSize,
79-
borderBoxWidth: entry.borderBoxSize[0].inlineSize,
80-
borderBoxHeight: entry.borderBoxSize[0].blockSize,
77+
contentBoxWidth: entry.contentBoxSize[0]?.inlineSize || 0,
78+
contentBoxHeight: entry.contentBoxSize[0]?.blockSize || 0,
79+
borderBoxWidth: entry.borderBoxSize[0]?.inlineSize || 0,
80+
borderBoxHeight: entry.borderBoxSize[0]?.blockSize || 0,
8181
};
8282
}
8383

0 commit comments

Comments
 (0)