Skip to content

Commit 849c6fd

Browse files
committed
Accordion: Avoid memory leak during refresh
Ref #10056 Closes jquerygh-1319
1 parent 2e8e52d commit 849c6fd

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

ui/accordion.js

+10-1
Original file line numberDiff line numberDiff line change
@@ -259,13 +259,22 @@ return $.widget( "ui.accordion", {
259259
},
260260

261261
_processPanels: function() {
262+
var prevHeaders = this.headers,
263+
prevPanels = this.panels;
264+
262265
this.headers = this.element.find( this.options.header )
263266
.addClass( "ui-accordion-header ui-state-default ui-corner-all" );
264267

265-
this.headers.next()
268+
this.panels = this.headers.next()
266269
.addClass( "ui-accordion-content ui-helper-reset ui-widget-content ui-corner-bottom" )
267270
.filter( ":not(.ui-accordion-content-active)" )
268271
.hide();
272+
273+
// Avoid memory leaks (#10056)
274+
if ( prevPanels ) {
275+
this._off( prevHeaders.not( this.headers ) );
276+
this._off( prevPanels.not( this.panels ) );
277+
}
269278
},
270279

271280
_refresh: function() {

0 commit comments

Comments
 (0)