mirror of
https://github.com/bitwarden/browser.git
synced 2025-02-22 02:21:34 +01:00
a11y title
This commit is contained in:
parent
e979dd4f12
commit
6ac679355d
28
src/angular/directives/a11y-title.directive.ts
Normal file
28
src/angular/directives/a11y-title.directive.ts
Normal file
@ -0,0 +1,28 @@
|
||||
import {
|
||||
Directive,
|
||||
ElementRef,
|
||||
Input,
|
||||
Renderer2,
|
||||
} from '@angular/core';
|
||||
|
||||
@Directive({
|
||||
selector: '[appA11yTitle]',
|
||||
})
|
||||
export class A11yTitleDirective {
|
||||
@Input() set appA11yTitle(title: string) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
private title: string;
|
||||
|
||||
constructor(private el: ElementRef, private renderer: Renderer2) { }
|
||||
|
||||
ngOnInit() {
|
||||
if (!this.el.nativeElement.hasAttribute('title')) {
|
||||
this.renderer.setAttribute(this.el.nativeElement, 'title', this.title);
|
||||
}
|
||||
if (!this.el.nativeElement.hasAttribute('aria-label')) {
|
||||
this.renderer.setAttribute(this.el.nativeElement, 'aria-label', this.title);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user