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

100% Statements 27/27
100% Branches 15/15
100% Functions 11/11
100% Lines 27/27

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 281x 1x 1x 1x 1x 1x 1x 1x 1x 3778x 3778x 3778x 1x 1x 1x 343x 343x 1x 1x 1x 574x 574x 1x 1x 1580x 1580x 1x  
import { Directive, ElementRef, HostListener } from '@angular/core';
 
import { FocusScopeDirective } from './focus-scope.directive';
 
@Directive({
  selector: '[data-gc-focus-target]',
})
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;
  }
}