-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Avoid memory leak with event bindings #1319
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -442,8 +442,14 @@ $.Widget.prototype = { | |
}, | ||
|
||
_off: function( element, eventName ) { | ||
eventName = (eventName || "").split( " " ).join( this.eventNamespace + " " ) + this.eventNamespace; | ||
eventName = (eventName || "").split( " " ).join( this.eventNamespace + " " ) + | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Grouping parens don't get spaces. Blame @dmethvin. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Seems like we never documented this decision. |
||
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 ) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a need to assign this to
this.panels
? Curious because it wasn't done before.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, so that we can get the previous value during a refresh.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah! I get it now.