mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2024-12-23 11:35:04 +01:00
Make changes
- use textContent where possible - make sure we have an image before adding title Signed-off-by: RMidhunSuresh <rmidhunsuresh@gmail.com>
This commit is contained in:
parent
b8c01272f4
commit
191613adbe
@ -68,17 +68,19 @@ export class AvatarView extends BaseUpdateView {
|
|||||||
this._root.replaceChild(renderImg(vm, this._size), this._root.firstChild);
|
this._root.replaceChild(renderImg(vm, this._size), this._root.firstChild);
|
||||||
this._root.classList.remove(bgColorClass);
|
this._root.classList.remove(bgColorClass);
|
||||||
} else {
|
} else {
|
||||||
this._root.replaceChild(text(vm.avatarLetter), this._root.firstChild);
|
this._root.textContent = vm.avatarLetter;
|
||||||
this._root.classList.add(bgColorClass);
|
this._root.classList.add(bgColorClass);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const hasAvatar = !!vm.avatarUrl(this._size);
|
const hasAvatar = !!vm.avatarUrl(this._size);
|
||||||
if (this._avatarTitleChanged() && hasAvatar) {
|
if (this._avatarTitleChanged() && hasAvatar) {
|
||||||
const img = this._root.firstChild;
|
const element = this._root.firstChild;
|
||||||
img.setAttribute("title", vm.avatarTitle);
|
if (element.tagName === "IMG") {
|
||||||
|
element.setAttribute("title", vm.avatarTitle);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (this._avatarLetterChanged() && !hasAvatar) {
|
if (this._avatarLetterChanged() && !hasAvatar) {
|
||||||
this._root.firstChild.textContent = vm.avatarLetter;
|
this._root.textContent = vm.avatarLetter;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user