Skip to content

Commit b397294

Browse files
committed
Widget: Avoid memory leaks when unbinding events with ._off()
Ref #10056 Ref jquerygh-1319
1 parent cedf91c commit b397294

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

ui/widget.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -442,8 +442,14 @@ $.Widget.prototype = {
442442
},
443443

444444
_off: function( element, eventName ) {
445-
eventName = (eventName || "").split( " " ).join( this.eventNamespace + " " ) + this.eventNamespace;
445+
eventName = (eventName || "").split( " " ).join( this.eventNamespace + " " ) +
446+
this.eventNamespace;
446447
element.unbind( eventName ).undelegate( eventName );
448+
449+
// Clear the stack to avoid memory leaks (#10056)
450+
this.bindings = $( this.bindings.not( element ).get() );
451+
this.focusable = $( this.focusable.not( element ).get() );
452+
this.hoverable = $( this.hoverable.not( element ).get() );
447453
},
448454

449455
_delay: function( handler, delay ) {

0 commit comments

Comments
 (0)