img on:error not fired
See original GitHub issueDescribe the bug If img cannot be loaded - on:error is not fired, refresh page is not helping. If modify code and let hmr update page contains img with on:error - error is fired.
Logs
To Reproduce https://github.com/asv1/svelte_bug_onerror
Expected behavior on:error must be fired.
Stacktraces Information about your SvelteKit Installation:
System:
OS: Windows 10 10.0.17763
CPU: (12) x64 AMD Ryzen 5 2600 Six-Core Processor
Memory: 12.90 GB / 15.93 GB
Binaries:
Node: 14.16.0 - d:\portable\node\node.EXE
npm: 6.14.11 - d:\portable\node\npm.CMD
npmPackages:
@sveltejs/kit: next => 1.0.0-next.78
svelte: ^3.29.0 => 3.37.0
vite: ^2.1.0 => 2.1.5
Severity Looks like on:load not fired too. Other handlers maybe too, not tested.
Additional context
Issue Analytics
- State:
- Created 2 years ago
- Comments:7 (1 by maintainers)
Top Results From Across the Web
Loading an image but onload/onerror not working as expected
Onload and onerror events are fired (executed) outside the scope of your function so your variables will be undefined.
Read more >Image Events aren't fired · Issue #7047 · vercel/next.js - GitHub
I have a similar issue with the onError . Only is fired sometimes using SSR... Navigating, always is firing the event (always that...
Read more >onerror on images not triggered when 404 response is an image
If the src of an <img> is a URL that returns 404, the onload event should fire on the image. This does not...
Read more >How to set a default image when an image fails to load
When an image fails to load due to connection, broken link, or whatever reason, the onerror event is fired. And this is where...
Read more >onerror Event - W3Schools
The onerror event is triggered if an error occurs while loading an external file (e.g. a document or an image). Tip: When used...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I could fix this by using
onerror=""
instead of svelte’son:error={}
.@Rich-Harris This works. I suppose that event listeners that originate directly from HTML elements can be attached at the right moment?
The language server seems to complain about that. Should I open a new ticket somewhere?