All files / lib/internal focus-target.directive.ts

100% Statements 28/28
100% Branches 10/10
100% Functions 6/6
100% Lines 28/28

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 291x 1x 1x 1x 1x 1x 1x 1x 1x 1x 2020x 2020x 2020x 1x 1x 1x 276x 276x 1x 1x 1x 513x 513x 1x 1x 888x 888x 1x  
import { Directive, ElementRef, HostListener } from '@angular/core';
 
import { FocusScopeDirective } from './focus-scope.directive';
 
@Directive({
  selector: '[data-gc-focus-target]',
  standalone: false,
})
export class FocusTargetDirective {
  constructor(
    private el: ElementRef<unknown>,
    private scope: FocusScopeDirective,
  ) {}
 
  @HostListener('blur', ['$event'])
  protected onBlur(event: FocusEvent): void {
    this.scope.onTargetBlur(event);
  }
 
  @HostListener('focus', ['$event'])
  protected onFocus(event: FocusEvent): void {
    this.scope.onTargetFocus(event);
  }
 
  public isFocusTarget(nativeElement: unknown): boolean {
    return this.el.nativeElement === nativeElement;
  }
}