Skip to content

Commit 2e8e52d

Browse files
committed
Tabs: Avoid memory leak during refresh
Fixes #10056 Ref jquerygh-1319
1 parent b397294 commit 2e8e52d

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

ui/tabs.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,10 @@ return $.widget( "ui.tabs", {
372372
},
373373

374374
_processTabs: function() {
375-
var that = this;
375+
var that = this,
376+
prevTabs = this.tabs,
377+
prevAnchors = this.anchors,
378+
prevPanels = this.panels;
376379

377380
this.tablist = this._getList()
378381
.addClass( "ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all" )
@@ -456,6 +459,13 @@ return $.widget( "ui.tabs", {
456459
this.panels
457460
.addClass( "ui-tabs-panel ui-widget-content ui-corner-bottom" )
458461
.attr( "role", "tabpanel" );
462+
463+
// Avoid memory leaks (#10056)
464+
if ( prevTabs ) {
465+
this._off( prevTabs.not( this.tabs ) );
466+
this._off( prevAnchors.not( this.anchors ) );
467+
this._off( prevPanels.not( this.panels ) );
468+
}
459469
},
460470

461471
// allow overriding how to find the list for rare usage scenarios (#7715)

0 commit comments

Comments
 (0)