Skip to content

Instantly share code, notes, and snippets.

@vanm
Created June 14, 2011 21:58
Show Gist options
  • Select an option

  • Save vanm/1026025 to your computer and use it in GitHub Desktop.

Select an option

Save vanm/1026025 to your computer and use it in GitHub Desktop.
jQuery cleanData
// --------------------------------------------------------
// Excerpt from jQuery's cleanData() (MIT Licence)
// Embrace circular references in event bindings, but clean up.
if ( data && data.events ) {
for ( var type in data.events ) {
if ( special[ type ] ) {
jQuery.event.remove( elem, type );
} else {
jQuery.removeEvent( elem, type, data.handle );
}
}
// Null the DOM reference to avoid IE6/7/8 leak (#7054)
if ( data.handle ) {
data.handle.elem = null;
}
}
// *** More cleanup/nullifying of attributes here ***
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment