From 276879bf97f2ee5f958477d0f31923ce4b420f87 Mon Sep 17 00:00:00 2001 From: Maksim Ivanov Date: Sat, 20 Jul 2024 11:41:06 +0300 Subject: [PATCH] fix(cdk): provided double value is non-finite (#8161) --- projects/cdk/utils/focus/set-native-mouse-focused.ts | 7 ++++++- .../cdk/utils/focus/tests/set-native-mouse-focused.spec.ts | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/projects/cdk/utils/focus/set-native-mouse-focused.ts b/projects/cdk/utils/focus/set-native-mouse-focused.ts index 8499a4f886c3..f2c11ea2ac85 100644 --- a/projects/cdk/utils/focus/set-native-mouse-focused.ts +++ b/projects/cdk/utils/focus/set-native-mouse-focused.ts @@ -15,7 +15,12 @@ export function tuiSetNativeMouseFocused( } if (typeof Event === 'function') { - element.dispatchEvent(new Event('mousedown', {bubbles: true, cancelable: true})); + element.dispatchEvent( + new MouseEvent('mousedown', { + bubbles: true, + cancelable: true, + }), + ); } else { const event = element.ownerDocument.createEvent('Event'); diff --git a/projects/cdk/utils/focus/tests/set-native-mouse-focused.spec.ts b/projects/cdk/utils/focus/tests/set-native-mouse-focused.spec.ts index 664c12cc0b30..367ee1fe6aa0 100644 --- a/projects/cdk/utils/focus/tests/set-native-mouse-focused.spec.ts +++ b/projects/cdk/utils/focus/tests/set-native-mouse-focused.spec.ts @@ -18,7 +18,7 @@ describe('tuiSetNativeMouseFocused', () => { tuiSetNativeMouseFocused(element); expect(mockDispatchEvent).toHaveBeenCalledWith( - new Event('mousedown', {bubbles: true, cancelable: true}), + new MouseEvent('mousedown', {bubbles: true, cancelable: true}), ); });