File tree Expand file tree Collapse file tree 3 files changed +22
-0
lines changed Expand file tree Collapse file tree 3 files changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -114,7 +114,19 @@ var Events = {
114114 */
115115 return jQueryHandlerValue !== undefined ? jQueryHandlerValue :
116116 nodeEventHandlerValue ;
117+ } ,
118+
119+ purge : function ( plotObj ) {
120+ delete plotObj . _ev ;
121+ delete plotObj . on ;
122+ delete plotObj . once ;
123+ delete plotObj . removeListener ;
124+ delete plotObj . removeAllListeners ;
125+ delete plotObj . emit ;
126+
127+ return plotObj ;
117128 }
129+
118130} ;
119131
120132module . exports = Events ;
Original file line number Diff line number Diff line change @@ -2412,6 +2412,9 @@ Plotly.purge = function purge(gd) {
24122412 // purge properties
24132413 Plots . purge ( gd ) ;
24142414
2415+ // purge event emitter methods
2416+ Events . purge ( gd ) ;
2417+
24152418 // remove plot container
24162419 if ( fullLayout . _container ) fullLayout . _container . remove ( ) ;
24172420
Original file line number Diff line number Diff line change @@ -181,8 +181,15 @@ describe('Events', function() {
181181 expect ( eventBaton ) . toBe ( 3 ) ;
182182 expect ( result ) . toBe ( 'pong' ) ;
183183 } ) ;
184+ } ) ;
184185
186+ describe ( 'purge' , function ( ) {
187+ it ( 'should remove all method from the plotObj' , function ( ) {
188+ Events . init ( plotObj ) ;
189+ Events . purge ( plotObj ) ;
185190
191+ expect ( plotObj ) . toEqual ( { } ) ;
192+ } ) ;
186193 } ) ;
187194
188195} ) ;
You can’t perform that action at this time.
0 commit comments