From 51420ada529782100c177814fecca76b4bd0e2f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pau=20Ferrer=20Oca=C3=B1a?= Date: Wed, 1 Feb 2023 11:52:02 +0100 Subject: [PATCH] MOBILE-4065 chore: Change to strict comparison in event key names --- src/core/classes/aria-role-tab.ts | 16 ++++++++-------- .../components/show-password/show-password.ts | 4 ++-- .../rich-text-editor/rich-text-editor.ts | 4 ++-- .../features/login/pages/reconnect/reconnect.ts | 4 ++-- src/core/singletons/dom.ts | 2 +- 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/core/classes/aria-role-tab.ts b/src/core/classes/aria-role-tab.ts index 3c7ea6938..2965eb3dc 100644 --- a/src/core/classes/aria-role-tab.ts +++ b/src/core/classes/aria-role-tab.ts @@ -29,19 +29,19 @@ export class CoreAriaRoleTab { * @param e Event. */ keyDown(tabFindIndex: string, e: KeyboardEvent): void { - if (e.key == ' ' || - e.key == 'Enter' || - e.key == 'Home' || - e.key == 'End' || - (this.isHorizontal() && (e.key == 'ArrowRight' || e.key == 'ArrowLeft')) || - (!this.isHorizontal() && (e.key == 'ArrowUp' ||e.key == 'ArrowDown')) + if (e.key === ' ' || + e.key === 'Enter' || + e.key === 'Home' || + e.key === 'End' || + (this.isHorizontal() && (e.key === 'ArrowRight' || e.key === 'ArrowLeft')) || + (!this.isHorizontal() && (e.key === 'ArrowUp' ||e.key === 'ArrowDown')) ) { e.preventDefault(); e.stopPropagation(); e.stopImmediatePropagation(); } - if (e.key == ' ' || e.key == 'Enter') { + if (e.key === ' ' || e.key === 'Enter') { this.selectTabCandidate = tabFindIndex; } } @@ -64,7 +64,7 @@ export class CoreAriaRoleTab { e.stopPropagation(); e.stopImmediatePropagation(); - if (e.key == ' ' || e.key == 'Enter') { + if (e.key === ' ' || e.key === 'Enter') { if (this.selectTabCandidate === tabFindIndex) { this.selectTab(tabFindIndex, e); } diff --git a/src/core/components/show-password/show-password.ts b/src/core/components/show-password/show-password.ts index 2ab247d28..12289e0d7 100644 --- a/src/core/components/show-password/show-password.ts +++ b/src/core/components/show-password/show-password.ts @@ -132,7 +132,7 @@ export class CoreShowPasswordComponent implements OnInit, AfterViewInit { * @param event The mouse event. */ doNotBlur(event: Event): void { - if (event.type == 'keydown' && !this.isValidKeyboardKey(event)) { + if (event.type === 'keydown' && !this.isValidKeyboardKey(event)) { return; } @@ -147,7 +147,7 @@ export class CoreShowPasswordComponent implements OnInit, AfterViewInit { * @returns Wether space or enter have been pressed. */ protected isValidKeyboardKey(event: KeyboardEvent): boolean { - return event.key == ' ' || event.key == 'Enter'; + return event.key === ' ' || event.key === 'Enter'; } } diff --git a/src/core/features/editor/components/rich-text-editor/rich-text-editor.ts b/src/core/features/editor/components/rich-text-editor/rich-text-editor.ts index e2d28827e..6b0e660c3 100644 --- a/src/core/features/editor/components/rich-text-editor/rich-text-editor.ts +++ b/src/core/features/editor/components/rich-text-editor/rich-text-editor.ts @@ -391,7 +391,7 @@ export class CoreEditorRichTextEditorComponent implements OnInit, AfterViewInit, this.stopBubble(event); - const move = event.key == 'ArrowLeft' ? -1 : +1; + const move = event.key === 'ArrowLeft' ? -1 : +1; const cursor = this.getCurrentCursorPosition(this.editorElement); this.setCurrentCursorPosition(this.editorElement, cursor + move); @@ -754,7 +754,7 @@ export class CoreEditorRichTextEditorComponent implements OnInit, AfterViewInit, * @returns Wether space or enter have been pressed. */ protected isValidKeyboardKey(event: KeyboardEvent): boolean { - return event.key == ' ' || event.key == 'Enter'; + return event.key === ' ' || event.key === 'Enter'; } /** diff --git a/src/core/features/login/pages/reconnect/reconnect.ts b/src/core/features/login/pages/reconnect/reconnect.ts index 973eeaee7..70fd73df1 100644 --- a/src/core/features/login/pages/reconnect/reconnect.ts +++ b/src/core/features/login/pages/reconnect/reconnect.ts @@ -353,7 +353,7 @@ export class CoreLoginReconnectPage implements OnInit, OnDestroy { * @param e Event. */ keyDown(e: KeyboardEvent): void { - if (e.key == 'Escape') { + if (e.key === 'Escape') { e.preventDefault(); e.stopPropagation(); } @@ -365,7 +365,7 @@ export class CoreLoginReconnectPage implements OnInit, OnDestroy { * @param e Event. */ keyUp(e: KeyboardEvent): void { - if (e.key == 'Escape') { + if (e.key === 'Escape') { this.cancel(e); } } diff --git a/src/core/singletons/dom.ts b/src/core/singletons/dom.ts index 262e65ebe..43e20abbe 100644 --- a/src/core/singletons/dom.ts +++ b/src/core/singletons/dom.ts @@ -519,7 +519,7 @@ export class CoreDom { element.addEventListener('click', (event) => callback(event)); element.addEventListener('keydown', (event) => { - if ((event.key == ' ' || event.key == 'Enter')) { + if (event.key === ' ' || event.key === 'Enter') { event.preventDefault(); event.stopPropagation(); }