]> source.dussan.org Git - jquery-ui.git/commitdiff
Accordion: Avoid memory leak during refresh
authorScott González <scott.gonzalez@gmail.com>
Wed, 20 Aug 2014 20:04:54 +0000 (16:04 -0400)
committerScott González <scott.gonzalez@gmail.com>
Thu, 21 Aug 2014 13:06:56 +0000 (09:06 -0400)
Ref #10056
Closes gh-1319

ui/accordion.js

index 5b748a3f22caf0f4cd53e738fc83b7c95a516bdb..946437197319e11bc78f00a24f0427ed731da2c0 100644 (file)
@@ -259,13 +259,22 @@ return $.widget( "ui.accordion", {
        },
 
        _processPanels: function() {
+               var prevHeaders = this.headers,
+                       prevPanels = this.panels;
+
                this.headers = this.element.find( this.options.header )
                        .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" )
                        .filter( ":not(.ui-accordion-content-active)" )
                        .hide();
+
+               // Avoid memory leaks (#10056)
+               if ( prevPanels ) {
+                       this._off( prevHeaders.not( this.headers ) );
+                       this._off( prevPanels.not( this.panels ) );
+               }
        },
 
        _refresh: function() {