From d57280e35cceb708fcab4d9ce3957ad184862b6b Mon Sep 17 00:00:00 2001 From: Joachim Desroches Date: Wed, 27 Nov 2024 16:04:23 +0100 Subject: [PATCH] Change test dom check from /jsdom/ to /jsdom|HappyDOM/. This change enables testing with Happy DOM without annoying warnings popping up. Fixes #10374. --- .../src/hooks/features/dimensions/useGridDimensions.ts | 2 +- .../hooks/features/virtualization/useGridVirtualScroller.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/x-data-grid/src/hooks/features/dimensions/useGridDimensions.ts b/packages/x-data-grid/src/hooks/features/dimensions/useGridDimensions.ts index dae588d1d1bd..c29918e30bbf 100644 --- a/packages/x-data-grid/src/hooks/features/dimensions/useGridDimensions.ts +++ b/packages/x-data-grid/src/hooks/features/dimensions/useGridDimensions.ts @@ -329,7 +329,7 @@ export function useGridDimensions( rootDimensionsRef.current = size; // jsdom has no layout capabilities - const isJSDOM = /jsdom/.test(window.navigator.userAgent); + const isJSDOM = /jsdom|HappyDOM/.test(window.navigator.userAgent); if (size.height === 0 && !errorShown.current && !props.autoHeight && !isJSDOM) { logger.error( diff --git a/packages/x-data-grid/src/hooks/features/virtualization/useGridVirtualScroller.tsx b/packages/x-data-grid/src/hooks/features/virtualization/useGridVirtualScroller.tsx index 679b05f8bbbb..499c21a66c40 100644 --- a/packages/x-data-grid/src/hooks/features/virtualization/useGridVirtualScroller.tsx +++ b/packages/x-data-grid/src/hooks/features/virtualization/useGridVirtualScroller.tsx @@ -92,7 +92,7 @@ type ScrollCache = ReturnType; let isJSDOM = false; try { if (typeof window !== 'undefined') { - isJSDOM = /jsdom/.test(window.navigator.userAgent); + isJSDOM = /jsdom|HappyDOM/.test(window.navigator.userAgent); } } catch (_) { /* ignore */