From 5107c663feda25f20399b2a4d7981646663275e8 Mon Sep 17 00:00:00 2001 From: Karl Seamon Date: Wed, 2 Oct 2024 14:30:46 -0400 Subject: [PATCH] handle missing ResizeObserver --- src/cdk/table/sticky-styler.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/cdk/table/sticky-styler.ts b/src/cdk/table/sticky-styler.ts index fb515aa32ff3..705a7eba8317 100644 --- a/src/cdk/table/sticky-styler.ts +++ b/src/cdk/table/sticky-styler.ts @@ -34,7 +34,9 @@ export const STICKY_DIRECTIONS: StickyDirection[] = ['top', 'bottom', 'left', 'r */ export class StickyStyler { private _elemSizeCache = new WeakMap(); - private _resizeObserver = new ResizeObserver(entries => this._updateCachedSizes(entries)); + private _resizeObserver = ResizeObserver + ? new ResizeObserver(entries => this._updateCachedSizes(entries)) + : null; private _updatedStickyColumnsParamsToReplay: UpdateStickyColumnsParams[] = []; private _stickyColumnsReplayTimeout: number | null = null; private _cachedCellWidths: number[] = []; @@ -448,6 +450,11 @@ export class StickyStyler { const clientRect = element.getBoundingClientRect(); const size = {width: clientRect.width, height: clientRect.height}; + + if (!this._resizeObserver) { + return size; + } + this._elemSizeCache.set(element, size); this._resizeObserver.observe(element, {box: 'border-box'}); return size;