diff --git a/lib/matplotlib/backends/web_backend/js/nbagg_mpl.js b/lib/matplotlib/backends/web_backend/js/nbagg_mpl.js index 9881819de855..0f538979d19d 100644 --- a/lib/matplotlib/backends/web_backend/js/nbagg_mpl.js +++ b/lib/matplotlib/backends/web_backend/js/nbagg_mpl.js @@ -48,11 +48,19 @@ mpl.mpl_figure_comm = function (comm, msg) { console.error('Failed to find cell for figure', id, fig); return; } + fig.cell_info[0].output_area.element.one( + 'cleared', + { fig: fig }, + fig._remove_fig_handler + ); }; mpl.figure.prototype.handle_close = function (fig, msg) { var width = fig.canvas.width / fig.ratio; - fig.root.removeEventListener('remove', this._remove_fig_handler); + fig.cell_info[0].output_area.element.off( + 'cleared', + fig._remove_fig_handler + ); // Update the output cell to use the data from the current canvas. fig.push_to_output(); @@ -171,13 +179,13 @@ mpl.figure.prototype._init_toolbar = function () { titlebar.insertBefore(buttongrp, titlebar.firstChild); }; -mpl.figure.prototype._remove_fig_handler = function () { - this.close_ws(this, {}); +mpl.figure.prototype._remove_fig_handler = function (event) { + var fig = event.data.fig; + fig.close_ws(fig, {}); }; mpl.figure.prototype._root_extra_style = function (el) { el.style.boxSizing = 'content-box'; // override notebook setting of border-box. - el.addEventListener('remove', this._remove_fig_handler); }; mpl.figure.prototype._canvas_extra_style = function (el) { diff --git a/requirements/testing/travis_extra.txt b/requirements/testing/travis_extra.txt index 19b774b382f7..0b18fc58394a 100644 --- a/requirements/testing/travis_extra.txt +++ b/requirements/testing/travis_extra.txt @@ -1,7 +1,7 @@ # Extra pip requirements for the travis python 3.7+ builds ipykernel -nbconvert[execute] +nbconvert[execute]!=6.0.0,!=6.0.1 nbformat!=5.0.0,!=5.0.1 pandas!=0.25.0 pikepdf