MOBILE-4065 chore: Change to strict comparison in event key names
parent
c1370250f5
commit
51420ada52
|
@ -29,19 +29,19 @@ export class CoreAriaRoleTab<T = unknown> {
|
|||
* @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<T = unknown> {
|
|||
e.stopPropagation();
|
||||
e.stopImmediatePropagation();
|
||||
|
||||
if (e.key == ' ' || e.key == 'Enter') {
|
||||
if (e.key === ' ' || e.key === 'Enter') {
|
||||
if (this.selectTabCandidate === tabFindIndex) {
|
||||
this.selectTab(tabFindIndex, e);
|
||||
}
|
||||
|
|
|
@ -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(<KeyboardEvent>event)) {
|
||||
if (event.type === 'keydown' && !this.isValidKeyboardKey(<KeyboardEvent>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';
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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';
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue