1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-10-30 08:10:34 +01:00
bitwarden-browser/libs/components/src/icon/icon.component.ts
Will Martin 9d4d340930
[SM-607] fix BitIcon innerHTML rerender removing click handler (#4949)
* remove innerHTML getter; update tests

* remove template; use hostbinding
2023-03-07 14:31:38 -05:00

25 lines
561 B
TypeScript

import { Component, HostBinding, Input } from "@angular/core";
import { DomSanitizer, SafeHtml } from "@angular/platform-browser";
import { Icon, isIcon } from "./icon";
@Component({
selector: "bit-icon",
template: ``,
})
export class BitIconComponent {
@Input() set icon(icon: Icon) {
if (!isIcon(icon)) {
this.innerHtml = "";
return;
}
const svg = icon.svg;
this.innerHtml = this.domSanitizer.bypassSecurityTrustHtml(svg);
}
@HostBinding() innerHtml: SafeHtml;
constructor(private domSanitizer: DomSanitizer) {}
}