Skip to content

Commit 51420ad

Browse files
committed
MOBILE-4065 chore: Change to strict comparison in event key names
1 parent c137025 commit 51420ad

File tree

5 files changed

+15
-15
lines changed

5 files changed

+15
-15
lines changed

src/core/classes/aria-role-tab.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,19 +29,19 @@ export class CoreAriaRoleTab<T = unknown> {
2929
* @param e Event.
3030
*/
3131
keyDown(tabFindIndex: string, e: KeyboardEvent): void {
32-
if (e.key == ' ' ||
33-
e.key == 'Enter' ||
34-
e.key == 'Home' ||
35-
e.key == 'End' ||
36-
(this.isHorizontal() && (e.key == 'ArrowRight' || e.key == 'ArrowLeft')) ||
37-
(!this.isHorizontal() && (e.key == 'ArrowUp' ||e.key == 'ArrowDown'))
32+
if (e.key === ' ' ||
33+
e.key === 'Enter' ||
34+
e.key === 'Home' ||
35+
e.key === 'End' ||
36+
(this.isHorizontal() && (e.key === 'ArrowRight' || e.key === 'ArrowLeft')) ||
37+
(!this.isHorizontal() && (e.key === 'ArrowUp' ||e.key === 'ArrowDown'))
3838
) {
3939
e.preventDefault();
4040
e.stopPropagation();
4141
e.stopImmediatePropagation();
4242
}
4343

44-
if (e.key == ' ' || e.key == 'Enter') {
44+
if (e.key === ' ' || e.key === 'Enter') {
4545
this.selectTabCandidate = tabFindIndex;
4646
}
4747
}
@@ -64,7 +64,7 @@ export class CoreAriaRoleTab<T = unknown> {
6464
e.stopPropagation();
6565
e.stopImmediatePropagation();
6666

67-
if (e.key == ' ' || e.key == 'Enter') {
67+
if (e.key === ' ' || e.key === 'Enter') {
6868
if (this.selectTabCandidate === tabFindIndex) {
6969
this.selectTab(tabFindIndex, e);
7070
}

src/core/components/show-password/show-password.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ export class CoreShowPasswordComponent implements OnInit, AfterViewInit {
132132
* @param event The mouse event.
133133
*/
134134
doNotBlur(event: Event): void {
135-
if (event.type == 'keydown' && !this.isValidKeyboardKey(<KeyboardEvent>event)) {
135+
if (event.type === 'keydown' && !this.isValidKeyboardKey(<KeyboardEvent>event)) {
136136
return;
137137
}
138138

@@ -147,7 +147,7 @@ export class CoreShowPasswordComponent implements OnInit, AfterViewInit {
147147
* @returns Wether space or enter have been pressed.
148148
*/
149149
protected isValidKeyboardKey(event: KeyboardEvent): boolean {
150-
return event.key == ' ' || event.key == 'Enter';
150+
return event.key === ' ' || event.key === 'Enter';
151151
}
152152

153153
}

src/core/features/editor/components/rich-text-editor/rich-text-editor.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ export class CoreEditorRichTextEditorComponent implements OnInit, AfterViewInit,
391391

392392
this.stopBubble(event);
393393

394-
const move = event.key == 'ArrowLeft' ? -1 : +1;
394+
const move = event.key === 'ArrowLeft' ? -1 : +1;
395395
const cursor = this.getCurrentCursorPosition(this.editorElement);
396396

397397
this.setCurrentCursorPosition(this.editorElement, cursor + move);
@@ -754,7 +754,7 @@ export class CoreEditorRichTextEditorComponent implements OnInit, AfterViewInit,
754754
* @returns Wether space or enter have been pressed.
755755
*/
756756
protected isValidKeyboardKey(event: KeyboardEvent): boolean {
757-
return event.key == ' ' || event.key == 'Enter';
757+
return event.key === ' ' || event.key === 'Enter';
758758
}
759759

760760
/**

src/core/features/login/pages/reconnect/reconnect.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ export class CoreLoginReconnectPage implements OnInit, OnDestroy {
353353
* @param e Event.
354354
*/
355355
keyDown(e: KeyboardEvent): void {
356-
if (e.key == 'Escape') {
356+
if (e.key === 'Escape') {
357357
e.preventDefault();
358358
e.stopPropagation();
359359
}
@@ -365,7 +365,7 @@ export class CoreLoginReconnectPage implements OnInit, OnDestroy {
365365
* @param e Event.
366366
*/
367367
keyUp(e: KeyboardEvent): void {
368-
if (e.key == 'Escape') {
368+
if (e.key === 'Escape') {
369369
this.cancel(e);
370370
}
371371
}

src/core/singletons/dom.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -519,7 +519,7 @@ export class CoreDom {
519519
element.addEventListener('click', (event) => callback(event));
520520

521521
element.addEventListener('keydown', (event) => {
522-
if ((event.key == ' ' || event.key == 'Enter')) {
522+
if (event.key === ' ' || event.key === 'Enter') {
523523
event.preventDefault();
524524
event.stopPropagation();
525525
}

0 commit comments

Comments
 (0)