]> source.dussan.org Git - jquery-ui.git/commitdiff
Widget: Avoid memory leaks when unbinding events with `._off()`
authorScott González <scott.gonzalez@gmail.com>
Wed, 20 Aug 2014 19:54:31 +0000 (15:54 -0400)
committerScott González <scott.gonzalez@gmail.com>
Thu, 21 Aug 2014 13:06:41 +0000 (09:06 -0400)
Ref #10056
Ref gh-1319

ui/widget.js

index d5a76c67dabb8d217f43dff56a655a96b4d29d71..6ef161591f5c78bd63f8a6281ed8f27b52ebf836 100644 (file)
@@ -442,8 +442,14 @@ $.Widget.prototype = {
        },
 
        _off: function( element, eventName ) {
-               eventName = (eventName || "").split( " " ).join( this.eventNamespace + " " ) + this.eventNamespace;
+               eventName = (eventName || "").split( " " ).join( this.eventNamespace + " " ) +
+                       this.eventNamespace;
                element.unbind( eventName ).undelegate( eventName );
+
+               // Clear the stack to avoid memory leaks (#10056)
+               this.bindings = $( this.bindings.not( element ).get() );
+               this.focusable = $( this.focusable.not( element ).get() );
+               this.hoverable = $( this.hoverable.not( element ).get() );
        },
 
        _delay: function( handler, delay ) {