You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
docuseal/app/javascript/elements/page_container.js

19 lines
489 B

export default class extends HTMLElement {
connectedCallback () {
const image = this.querySelector('img')
this.setAttribute('role', 'img')
if (image?.alt) {
this.setAttribute('aria-label', image.alt)
}
image.addEventListener('load', (e) => {
image.setAttribute('width', e.target.naturalWidth)
image.setAttribute('height', e.target.naturalHeight)
this.style.aspectRatio = `${e.target.naturalWidth} / ${e.target.naturalHeight}`
})
}
}