From c91b284d70db62aa07bd5b6d38576a7c560a7349 Mon Sep 17 00:00:00 2001 From: Lightling Date: Sun, 23 Jun 2024 12:17:22 -0400 Subject: [PATCH] wrap link icon --- libs/embeds/src/link.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/libs/embeds/src/link.ts b/libs/embeds/src/link.ts index 943fd6c..dab17de 100644 --- a/libs/embeds/src/link.ts +++ b/libs/embeds/src/link.ts @@ -63,18 +63,22 @@ export class LinkEmbed extends HTMLElement { } this.append(_link) + const _iconWrapper = ownerDocument.createElement('div') + _iconWrapper.classList.add('icon-wrapper') + _link.append(_iconWrapper) + const _icon = ownerDocument.createElement('img') - _link.append(_icon) _icon.alt = '' // decorative _icon.classList.add('no-inflate') + _iconWrapper.append(_icon) this._observers.icon = { element: _icon, observer: (oldVal, newVal) => { - const { element } = this._observers.icon if (!!newVal) { - element!.setAttribute('src', newVal) + _icon.setAttribute('src', newVal) + _iconWrapper.style.display = 'inherit' } else { - element!.style.display = 'hidden' + _iconWrapper.style.display = 'hidden' } }, }