mirror of
https://github.com/bitwarden/browser
synced 2025-12-18 09:13:33 +00:00
[PM-5189] Add a fallback for image assets that do not load correctly
This commit is contained in:
@@ -79,6 +79,8 @@ export class AutofillOverlayInlineMenuElements implements InlineMenuElementsInte
|
||||
* longer triggers.
|
||||
*/
|
||||
private removeInlineMenu = (message?: AutofillExtensionMessage) => {
|
||||
return;
|
||||
|
||||
if (message?.overlayElement === AutofillOverlayElement.Button) {
|
||||
this.removeInlineMenuButton();
|
||||
return;
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user