1
0
mirror of https://github.com/bitwarden/browser.git synced 2025-01-26 22:01:32 +01:00

[PM-5189] Add a fallback for image assets that do not load correctly

This commit is contained in:
Cesar Gonzalez 2024-05-01 00:37:51 -05:00
parent 7994e6072a
commit 828e187dc4
No known key found for this signature in database
GPG Key ID: 3381A5457F8CCECF
2 changed files with 11 additions and 0 deletions

View File

@ -79,6 +79,8 @@ export class AutofillOverlayInlineMenuElements implements InlineMenuElementsInte
* longer triggers.
*/
private removeInlineMenu = (message?: AutofillExtensionMessage) => {
return;
if (message?.overlayElement === AutofillOverlayElement.Button) {
this.removeInlineMenuButton();
return;

View File

@ -397,6 +397,15 @@ class AutofillOverlayList extends AutofillOverlayPageElement {
try {
const url = new URL(cipher.icon.image);
cipherIcon.style.backgroundImage = `url(${url.href})`;
const dummyImageElement = globalThis.document.createElement("img");
dummyImageElement.src = url.href;
dummyImageElement.addEventListener("error", () => {
cipherIcon.style.backgroundImage = "";
cipherIcon.classList.add("cipher-icon", "bwi", cipher.icon.icon);
});
dummyImageElement.remove();
return cipherIcon;
} catch {
// Silently default to the globe icon element if the image URL is invalid