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.

Missing onLoad and onError events on SVG <image> tag

See original GitHub issue

SVG <image> is supposed as far as I know to support at least the same onload and onerror events <img> supports.

From looking at React code the events are handled on specific elements in ReactDOMComponents.js in trapBubbledEventsLocal, mountComponent, unmountComponent.

It would be easy to create a pull request to add ‘image’ to these cases, but it seems that there is a separation between js files that handle DOM and SVG in the codebase that this might collide with.

Am I correct and there is more to it than just adding more cases? Or these functions are the right place to also handle SVG image?

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Reactions:22
  • Comments:12 (6 by maintainers)

github_iconTop GitHub Comments

4reactions
Simekcommented, May 7, 2017

I’ve commited PR which adds onLoad and onError events to SVG, but we are still missing few others like onUnload, onResize, onScroll, onZoom etc. Thank you @gaearon for mentioning correct file name.

2reactions
gaearoncommented, Nov 8, 2016

If you’re interested in this, could you please send a PR? Yes I think ReactDOMComponent.js is the right place for this.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Image onload not called when setting source - Stack Overflow
Because it is NOT ok -. missing quote in your svg string; the image triggers the error and not the load handler. var...
Read more >
Resource loading: onload and onerror
Most resources start loading when they are added to the document. But <img> is an exception. It starts loading when it gets a...
Read more >
next/image - Next.js
Enable Image Optimization with the built-in Image component. ... onError. A callback function that is invoked if the image fails to load.
Read more >
XSS Filter Evasion - OWASP Cheat Sheet Series
Inserting JavaScript in an event method will also apply to any HTML tag type ... <img src=x onerror="&#0000106&#0000097&#0000118&#0000097&#0000115&#0000099& ...
Read more >
HTML5 Security Cheatsheet
Novel here is that the "srcset" attribute allows to trigger load events. ... Missing attributes for the <img> tag such as "onerror" are...
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