From: Scott González Date: Wed, 20 Aug 2014 19:54:31 +0000 (-0400) Subject: Widget: Avoid memory leaks when unbinding events with `._off()` X-Git-Tag: 1.11.2~39 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=b397294d42e783aacd4cc3a52bbe3aacc0f3f725;p=jquery-ui.git Widget: Avoid memory leaks when unbinding events with `._off()` Ref #10056 Ref gh-1319 --- diff --git a/ui/widget.js b/ui/widget.js index d5a76c67d..6ef161591 100644 --- a/ui/widget.js +++ b/ui/widget.js @@ -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 ) {