0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2025-01-20 22:12:38 -05:00

[Toolbar] Remove image decode call (#9305)

* stop waiting for images to decode

* fix: don't add empty audits

---------

Co-authored-by: Princesseuh <3019731+Princesseuh@users.noreply.github.com>
This commit is contained in:
Fred K. Schott 2023-12-05 04:14:34 -08:00 committed by GitHub
parent 30982078e6
commit 7b6ae08348
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -135,7 +135,7 @@ export default {
margin: 0;
font-size: 22px;
}
astro-dev-toolbar-icon {
width: 1em;
height: 1em;
@ -187,13 +187,13 @@ export default {
// If the element is hidden, don't do anything
if (targetedElement.offsetParent === null || computedStyle.display === 'none') {
audits.push();
return;
}
// If the element is an image, wait for it to load
// If the element is an image but not yet loaded, ignore it
// TODO: We shouldn't ignore this, because it is valid for an image to not be loaded at start (e.g. lazy loading)
if (originalElement.nodeName === 'IMG' && !(originalElement as HTMLImageElement).complete) {
await (originalElement as HTMLImageElement).decode();
return;
}
const rect = originalElement.getBoundingClientRect();