Skip to content

Commit

Permalink
handle missing ResizeObserver
Browse files Browse the repository at this point in the history
  • Loading branch information
kseamon committed Oct 2, 2024
1 parent 470a3f5 commit 5107c66
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/cdk/table/sticky-styler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ export const STICKY_DIRECTIONS: StickyDirection[] = ['top', 'bottom', 'left', 'r
*/
export class StickyStyler {
private _elemSizeCache = new WeakMap<HTMLElement, {width: number; height: number}>();
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[] = [];
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 5107c66

Please sign in to comment.