Accordion: Avoid memory leak during refresh

Ref #10056
Closes gh-1319
This commit is contained in:
Scott González 2014-08-20 16:04:54 -04:00
parent 2e8e52dec1
commit 849c6fd537

View File

@ -259,13 +259,22 @@ return $.widget( "ui.accordion", {
}, },
_processPanels: function() { _processPanels: function() {
var prevHeaders = this.headers,
prevPanels = this.panels;
this.headers = this.element.find( this.options.header ) this.headers = this.element.find( this.options.header )
.addClass( "ui-accordion-header ui-state-default ui-corner-all" ); .addClass( "ui-accordion-header ui-state-default ui-corner-all" );
this.headers.next() this.panels = this.headers.next()
.addClass( "ui-accordion-content ui-helper-reset ui-widget-content ui-corner-bottom" ) .addClass( "ui-accordion-content ui-helper-reset ui-widget-content ui-corner-bottom" )
.filter( ":not(.ui-accordion-content-active)" ) .filter( ":not(.ui-accordion-content-active)" )
.hide(); .hide();
// Avoid memory leaks (#10056)
if ( prevPanels ) {
this._off( prevHeaders.not( this.headers ) );
this._off( prevPanels.not( this.panels ) );
}
}, },
_refresh: function() { _refresh: function() {