wrap link icon

This commit is contained in:
lightling 2024-06-23 12:17:22 -04:00
parent 370ce0cefe
commit c91b284d70

View file

@ -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'
}
},
}