Skip to content

Commit

Permalink
Consistently clean up after .ready() handler, close gh-1135.
Browse files Browse the repository at this point in the history
  • Loading branch information
markelog authored and dmethvin committed Jan 20, 2013
1 parent 1ad874f commit dbf4926
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/core.js
Expand Up @@ -62,8 +62,9 @@ var
},

// The ready event handler and self cleanup method
DOMContentLoaded = function() {
document.removeEventListener( "DOMContentLoaded", DOMContentLoaded, false );
completed = function() {
document.removeEventListener( "DOMContentLoaded", completed, false );
window.removeEventListener( "load", completed, false );
jQuery.ready();
};

Expand Down Expand Up @@ -770,13 +771,13 @@ jQuery.ready.promise = function( obj ) {
// Handle it asynchronously to allow scripts the opportunity to delay ready
setTimeout( jQuery.ready );

// Standards-based browsers support DOMContentLoaded
} else {

// Use the handy event callback
document.addEventListener( "DOMContentLoaded", DOMContentLoaded, false );
document.addEventListener( "DOMContentLoaded", completed, false );

// A fallback to window.onload, that will always work
window.addEventListener( "load", jQuery.ready, false );
window.addEventListener( "load", completed, false );
}
}
return readyList.promise( obj );
Expand Down

0 comments on commit dbf4926

Please sign in to comment.