Missing onLoad and onError events on SVG <image> tag
See original GitHub issueSVG <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:
- Created 8 years ago
- Reactions:22
- Comments:12 (6 by maintainers)
Top 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="javasc& ...
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 >
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 Free
Top 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
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.
If you’re interested in this, could you please send a PR? Yes I think
ReactDOMComponent.js
is the right place for this.