]> source.dussan.org Git - jquery-ui.git/commitdiff
Tabs: Avoid memory leak during refresh
authorScott González <scott.gonzalez@gmail.com>
Wed, 20 Aug 2014 19:57:12 +0000 (15:57 -0400)
committerScott González <scott.gonzalez@gmail.com>
Thu, 21 Aug 2014 13:06:49 +0000 (09:06 -0400)
Fixes #10056
Ref gh-1319

ui/tabs.js

index c45d6b3f6f7e138c7700a219466bf4b042caa25a..e45a97c726c7f7fe11122c07f6ed2baefa944419 100644 (file)
@@ -372,7 +372,10 @@ return $.widget( "ui.tabs", {
        },
 
        _processTabs: function() {
-               var that = this;
+               var that = this,
+                       prevTabs = this.tabs,
+                       prevAnchors = this.anchors,
+                       prevPanels = this.panels;
 
                this.tablist = this._getList()
                        .addClass( "ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all" )
@@ -456,6 +459,13 @@ return $.widget( "ui.tabs", {
                this.panels
                        .addClass( "ui-tabs-panel ui-widget-content ui-corner-bottom" )
                        .attr( "role", "tabpanel" );
+
+               // Avoid memory leaks (#10056)
+               if ( prevTabs ) {
+                       this._off( prevTabs.not( this.tabs ) );
+                       this._off( prevAnchors.not( this.anchors ) );
+                       this._off( prevPanels.not( this.panels ) );
+               }
        },
 
        // allow overriding how to find the list for rare usage scenarios (#7715)