@@ -48,11 +48,19 @@ mpl.mpl_figure_comm = function (comm, msg) {
48
48
console . error ( 'Failed to find cell for figure' , id , fig ) ;
49
49
return ;
50
50
}
51
+ fig . cell_info [ 0 ] . output_area . element . one (
52
+ 'cleared' ,
53
+ { fig : fig } ,
54
+ fig . _remove_fig_handler
55
+ ) ;
51
56
} ;
52
57
53
58
mpl . figure . prototype . handle_close = function ( fig , msg ) {
54
59
var width = fig . canvas . width / fig . ratio ;
55
- fig . root . removeEventListener ( 'remove' , this . _remove_fig_handler ) ;
60
+ fig . cell_info [ 0 ] . output_area . element . off (
61
+ 'cleared' ,
62
+ fig . _remove_fig_handler
63
+ ) ;
56
64
57
65
// Update the output cell to use the data from the current canvas.
58
66
fig . push_to_output ( ) ;
@@ -171,13 +179,13 @@ mpl.figure.prototype._init_toolbar = function () {
171
179
titlebar . insertBefore ( buttongrp , titlebar . firstChild ) ;
172
180
} ;
173
181
174
- mpl . figure . prototype . _remove_fig_handler = function ( ) {
175
- this . close_ws ( this , { } ) ;
182
+ mpl . figure . prototype . _remove_fig_handler = function ( event ) {
183
+ var fig = event . data . fig ;
184
+ fig . close_ws ( fig , { } ) ;
176
185
} ;
177
186
178
187
mpl . figure . prototype . _root_extra_style = function ( el ) {
179
188
el . style . boxSizing = 'content-box' ; // override notebook setting of border-box.
180
- el . addEventListener ( 'remove' , this . _remove_fig_handler ) ;
181
189
} ;
182
190
183
191
mpl . figure . prototype . _canvas_extra_style = function ( el ) {
0 commit comments