mirror of
https://github.com/bitwarden/browser.git
synced 2024-06-26 10:35:48 +02:00
* [deps] Autofill: Update prettier to v3 * prettier formatting updates --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Jonathan Prusik <jprusik@classynemesis.com>
30 lines
799 B
TypeScript
30 lines
799 B
TypeScript
import { Directive, ElementRef, OnDestroy, OnInit } from "@angular/core";
|
|
import { NgControl } from "@angular/forms";
|
|
import { Subscription } from "rxjs";
|
|
|
|
@Directive({
|
|
selector: "[appA11yInvalid]",
|
|
})
|
|
export class A11yInvalidDirective implements OnDestroy, OnInit {
|
|
private sub: Subscription;
|
|
|
|
constructor(
|
|
private el: ElementRef<HTMLInputElement>,
|
|
private formControlDirective: NgControl,
|
|
) {}
|
|
|
|
ngOnInit() {
|
|
this.sub = this.formControlDirective.control.statusChanges.subscribe((status) => {
|
|
if (status === "INVALID") {
|
|
this.el.nativeElement.setAttribute("aria-invalid", "true");
|
|
} else if (status === "VALID") {
|
|
this.el.nativeElement.setAttribute("aria-invalid", "false");
|
|
}
|
|
});
|
|
}
|
|
|
|
ngOnDestroy() {
|
|
this.sub?.unsubscribe();
|
|
}
|
|
}
|