From 191613adbecfcd89e667970ebd4c28435267a83c Mon Sep 17 00:00:00 2001 From: RMidhunSuresh Date: Thu, 1 Jul 2021 19:21:54 +0530 Subject: [PATCH] Make changes - use textContent where possible - make sure we have an image before adding title Signed-off-by: RMidhunSuresh --- src/platform/web/ui/AvatarView.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/platform/web/ui/AvatarView.js b/src/platform/web/ui/AvatarView.js index 22381838..1f6f2736 100644 --- a/src/platform/web/ui/AvatarView.js +++ b/src/platform/web/ui/AvatarView.js @@ -68,17 +68,19 @@ export class AvatarView extends BaseUpdateView { this._root.replaceChild(renderImg(vm, this._size), this._root.firstChild); this._root.classList.remove(bgColorClass); } else { - this._root.replaceChild(text(vm.avatarLetter), this._root.firstChild); + this._root.textContent = vm.avatarLetter; this._root.classList.add(bgColorClass); } } const hasAvatar = !!vm.avatarUrl(this._size); if (this._avatarTitleChanged() && hasAvatar) { - const img = this._root.firstChild; - img.setAttribute("title", vm.avatarTitle); + const element = this._root.firstChild; + if (element.tagName === "IMG") { + element.setAttribute("title", vm.avatarTitle); + } } if (this._avatarLetterChanged() && !hasAvatar) { - this._root.firstChild.textContent = vm.avatarLetter; + this._root.textContent = vm.avatarLetter; } } }