Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clarify image.decode() failure on lazy-loaded images #38034

Open
marcustyphoon opened this issue Feb 8, 2025 · 0 comments
Open

Clarify image.decode() failure on lazy-loaded images #38034

marcustyphoon opened this issue Feb 8, 2025 · 0 comments
Labels
area: DOM/CSSOM Content:WebAPI Web API docs help wanted If you know something about this topic, we would love your help!

Comments

@marcustyphoon
Copy link
Contributor

marcustyphoon commented Feb 8, 2025

MDN URL

https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/decode

What specific section or headline is this issue about?

Missing information

What information was incorrect, unhelpful, or incomplete?

As noted in https://stackoverflow.com/questions/65146920/domexception-invalid-image-request, the decode() function will throw EncodingError: Invalid image request. on images with loading="lazy" that have not yet loaded in Firefox; it will not do so in Chrome. This is either a browser bug, an indication that the page information ("This can be used to initiate loading of the image") is somewhat incomplete/misleading, or just of a case of undefined behavior which might deserve a note.

What did you expect to see?

Either just a note that this loading="lazy" case fails in Firefox on images that have not yet loaded, or an explanation of the difference between loading and decoding/when decoding might fail if this is actually a symptom of a larger degree of complexity.

edit: Per further testing, calling decode() in an onload handler works and functions correctly on a loading="lazy" image; it's only calling it too early that fails.

Do you have any supporting links, references, or citations?

The only semi-relevant Firefox bug I found is https://bugzilla.mozilla.org/show_bug.cgi?id=1758035, which links to the spec. It's still not entirely clear from the spec text to me whether the function is explicitly supposed to interact with/wait for loading, and if so exactly how.

Do you have anything more you want to share?

No response

MDN metadata

Page report details
@marcustyphoon marcustyphoon added the needs triage Triage needed by staff and/or partners. Automatically applied when an issue is opened. label Feb 8, 2025
@github-actions github-actions bot added the Content:WebAPI Web API docs label Feb 8, 2025
@marcustyphoon marcustyphoon changed the title Clarify image.decode() valid uses Clarify image.decode() failure on lazy-loaded images Feb 8, 2025
@Josh-Cena Josh-Cena added help wanted If you know something about this topic, we would love your help! area: DOM/CSSOM and removed needs triage Triage needed by staff and/or partners. Automatically applied when an issue is opened. labels Feb 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: DOM/CSSOM Content:WebAPI Web API docs help wanted If you know something about this topic, we would love your help!
Projects
None yet
Development

No branches or pull requests

2 participants