From fd3e5246369ec535a4795e1bf05fd4b4a4bd1f2c Mon Sep 17 00:00:00 2001 From: Gethin Webster Date: Mon, 12 Jun 2023 16:57:23 +0200 Subject: [PATCH] Optional `matchMedia` calls --- src/code-editor/util.ts | 2 +- src/internal/hooks/use-visual-mode/index.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/code-editor/util.ts b/src/code-editor/util.ts index 4f87c0cfdd..e7f69a90fc 100644 --- a/src/code-editor/util.ts +++ b/src/code-editor/util.ts @@ -23,7 +23,7 @@ export function getDefaultTheme(element: HTMLElement): CodeEditorProps.Theme { !!findUpUntil( element, node => node.classList.contains('awsui-polaris-dark-mode') || node.classList.contains('awsui-dark-mode') - ) && !window?.matchMedia('print').matches; + ) && !window?.matchMedia?.('print').matches; return isDarkMode ? DEFAULT_DARK_THEME : DEFAULT_LIGHT_THEME; } diff --git a/src/internal/hooks/use-visual-mode/index.ts b/src/internal/hooks/use-visual-mode/index.ts index 4b9f2074fc..56154ae29c 100644 --- a/src/internal/hooks/use-visual-mode/index.ts +++ b/src/internal/hooks/use-visual-mode/index.ts @@ -15,7 +15,7 @@ export function useCurrentMode(elementRef: React.RefObject) { findUpUntil( node, node => node.classList.contains('awsui-polaris-dark-mode') || node.classList.contains('awsui-dark-mode') - ) && !window?.matchMedia('print').matches; + ) && !window?.matchMedia?.('print').matches; setValue(darkModeParent ? 'dark' : 'light'); }); return value;