question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

img on:error not fired

See original GitHub issue

Describe 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:closed
  • Created 2 years ago
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
dimdenGDcommented, Oct 23, 2021

I could fix this by using onerror="" instead of svelte’s on:error={}.

0reactions
maximeduprecommented, Sep 26, 2022

I could fix this by using onerror=“” instead of svelte’s on:error={}.

@Rich-Harris This works. I suppose that event listeners that originate directly from HTML elements can be attached at the right moment?

Xnapper-2022-09-26-10 46 00

The language server seems to complain about that. Should I open a new ticket somewhere?

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found