[Bug]: webagg backend uses non-existent unload event
Bug summary
The webagg backend uses the onunload attribute of the image to close the websocket:
https://github.com/matplotlib/matplotlib/blob/c1afaeca985ba7cfce0bfcef40a315f641855456/lib/matplotlib/backends/web_backend/js/mpl.js#L83-L85
I cannot find any such event for Images, for its parent HTMLElement interface, or for its parent Element class, or even the Node ABC.
The docs for the unload event say that it is only on the global Window interface, with onunload on the body, frameset, and svg elements. It is also not recommended for use.
Code for reproduction
In the browser console:
var img = new Image();
img.on<TAB>Actual outcome
There is no onunload in the autocomplete in the browser console.
Expected outcome
We should remove the onunload entirely, but I am uncertain as to whether we should be closing the websocket explicitly somewhere else.
Matplotlib Version
main
Matplotlib Backend
WebAgg
Installation
git checkout
Source: matplotlib/matplotlib