-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Svelte 5: onerror event is not called on img element #10352
Comments
I'm assuming you're using SSR when you see the error, hence why it's fine in the REPL. The image finishes loading or errors before the javascript does so it misses the event... You can maybe workaround it with something like, or some global script that replays the events function action(img, onerror) {
img.onerror = onerror;
img_2.onload = () => img.onerror = null;
const img_2= new Image();
img_2.src = img.src;
} |
I can't find it right now, but this has come up before. I don't think we should have special behavior for The lack of a definitive heuristic for what constitutes an image that has failed to load is what made us hesitant to offer a built-in action that did this, I think. |
Back when I ran into this problem, my "heuristic" of choice was |
I'm not using SSR and what I'm trying to achieve works perfectly fine in Svelte 4. The code is written in the main +page and this issue is only happening after immigration to Svelte 5. |
Can you provide a reproduction where this works fine in Svelte 4? |
You are right and I can't seem to recreate it properly. Just like you said it will run fine if it's only on the client. |
Closing this for now then :) |
Describe the bug
I noticed that the onerror event is not called when using an img element. weirdly it works in the playground so test it on your own machine.
Reproduction
The onerror event is not called even though a 404 error is thrown
Logs
No response
System Info
Severity
annoyance
The text was updated successfully, but these errors were encountered: