[SM-607] fix BitIcon innerHTML rerender removing click handler (#4949)

* remove innerHTML getter; update tests

* remove template; use hostbinding
This commit is contained in:
Will Martin 2023-03-07 14:31:38 -05:00 committed by GitHub
parent 0ff3c679c9
commit 9d4d340930
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 9 deletions

View File

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