Commit dbf4926e authored by Oleg's avatar Oleg Committed by Dave Methvin

Consistently clean up after .ready() handler, close gh-1135.

parent 1ad874f3
...@@ -62,8 +62,9 @@ var ...@@ -62,8 +62,9 @@ var
}, },
// The ready event handler and self cleanup method // The ready event handler and self cleanup method
DOMContentLoaded = function() { completed = function() {
document.removeEventListener( "DOMContentLoaded", DOMContentLoaded, false ); document.removeEventListener( "DOMContentLoaded", completed, false );
window.removeEventListener( "load", completed, false );
jQuery.ready(); jQuery.ready();
}; };
...@@ -770,13 +771,13 @@ jQuery.ready.promise = function( obj ) { ...@@ -770,13 +771,13 @@ jQuery.ready.promise = function( obj ) {
// Handle it asynchronously to allow scripts the opportunity to delay ready // Handle it asynchronously to allow scripts the opportunity to delay ready
setTimeout( jQuery.ready ); setTimeout( jQuery.ready );
// Standards-based browsers support DOMContentLoaded
} else { } else {
// Use the handy event callback // Use the handy event callback
document.addEventListener( "DOMContentLoaded", DOMContentLoaded, false ); document.addEventListener( "DOMContentLoaded", completed, false );
// A fallback to window.onload, that will always work // A fallback to window.onload, that will always work
window.addEventListener( "load", jQuery.ready, false ); window.addEventListener( "load", completed, false );
} }
} }
return readyList.promise( obj ); return readyList.promise( obj );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment