diff options
author | Scott González <scott.gonzalez@gmail.com> | 2014-08-20 15:54:31 -0400 |
---|---|---|
committer | Scott González <scott.gonzalez@gmail.com> | 2014-08-21 09:06:41 -0400 |
commit | b397294d42e783aacd4cc3a52bbe3aacc0f3f725 (patch) | |
tree | a07973987ddfbb5b76ed71bf765e8a56385c1b2b /ui/widget.js | |
parent | cedf91c0a9d2cf75f0907b9e098eacc6f1ba0891 (diff) | |
download | jquery-ui-b397294d42e783aacd4cc3a52bbe3aacc0f3f725.tar.gz jquery-ui-b397294d42e783aacd4cc3a52bbe3aacc0f3f725.zip |
Widget: Avoid memory leaks when unbinding events with `._off()`
Ref #10056
Ref gh-1319
Diffstat (limited to 'ui/widget.js')
-rw-r--r-- | ui/widget.js | 8 |
1 files changed, 7 insertions, 1 deletions
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 ) { |