You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
varimg=newImage();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.
Confirmed — onunload doesn't exist anywhere on the Image prototype chain (HTMLImageElement → HTMLElement → Element → Node), so the assignment at mpl.js:83-85 is a plain expando property that no browser has ever invoked. It's been dead code since it was introduced.
Re: your uncertainty about closing the websocket explicitly — I don't think it's needed:
On page teardown the browser is required to close all open WebSocket connections, and the tornado side already handles that path: WebSocketHandler.on_close → FigureManagerWebAgg.remove_web_socket cleans up the server-side set.
For nbagg, the comm is closed by Jupyter's own comm lifecycle (comm.on_close in backend_nbagg.py), independent of this handler.
So removing the handler outright is behavior-neutral (it never fired) and leaves the real cleanup paths untouched. I'll push a PR removing it shortly.
Activity
kokhlo commentedon Sep 26, 2026
Confirmed —
onunloaddoesn't exist anywhere on theImageprototype chain (HTMLImageElement→HTMLElement→Element→Node), so the assignment at mpl.js:83-85 is a plain expando property that no browser has ever invoked. It's been dead code since it was introduced.Re: your uncertainty about closing the websocket explicitly — I don't think it's needed:
WebSocketHandler.on_close→FigureManagerWebAgg.remove_web_socketcleans up the server-side set.comm.on_closein backend_nbagg.py), independent of this handler.So removing the handler outright is behavior-neutral (it never fired) and leaves the real cleanup paths untouched. I'll push a PR removing it shortly.