From b397294d42e783aacd4cc3a52bbe3aacc0f3f725 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Scott=20Gonz=C3=A1lez?= Date: Wed, 20 Aug 2014 15:54:31 -0400 Subject: [PATCH] Widget: Avoid memory leaks when unbinding events with `._off()` Ref #10056 Ref gh-1319 --- ui/widget.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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 ) { -- 2.39.5