mirror of
https://github.com/bitwarden/browser
synced 2025-12-13 14:53:33 +00:00
Adds standalone: false to all components since Angular is changing the default to true and we'd rather not have the angular PR change 300+ files.
33 lines
914 B
TypeScript
33 lines
914 B
TypeScript
// FIXME: Update this file to be type safe and remove this and next line
|
|
// @ts-strict-ignore
|
|
import { Directive, ElementRef, OnDestroy, OnInit } from "@angular/core";
|
|
import { NgControl } from "@angular/forms";
|
|
import { Subscription } from "rxjs";
|
|
|
|
@Directive({
|
|
selector: "[appA11yInvalid]",
|
|
standalone: false,
|
|
})
|
|
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();
|
|
}
|
|
}
|