Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

2.0: Removes attachEvent paths for jQuery.ready() #1077

Closed
wants to merge 2 commits into from

3 participants

Rick Waldron dherman Dave Methvin
Rick Waldron
Collaborator

I couldn't wait until next Monday.

Sizes - compared to master @ 5c8984efc4a8c0472bcdc514e744b063e8f98a61
    264496     (-1214)  dist/jquery.js                                         
     92254      (-382)  dist/jquery.min.js                                     
     32694      (-113)  dist/jquery.min.js.gz  

Signed-off-by: Rick Waldron waldron.rick@gmail.com

Rick Waldron rwaldron 2.0: Removes attachEvent paths for jQuery.ready()
Signed-off-by: Rick Waldron <waldron.rick@gmail.com>
c4e1784
dherman

Just curious - it looks like cleanup is happening for the DOMContentLoaded event but not the load event even though if one is bound, so is the other.

Rick Waldron rwaldron Remove setTimeout for body existance
Signed-off-by: Rick Waldron <waldron.rick@gmail.com>
578a5c3
Rick Waldron
Collaborator

@dcherman you're right! load is handled in events.js, which @dmethvin is currently setting on :fire:

Dave Methvin
Owner

Wouldn't we clean up the handler in jQuery.ready with window.removeEventListener( "load", jQuery.ready, false ); now?

Rick Waldron rwaldron closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Dec 17, 2012
  1. Rick Waldron

    2.0: Removes attachEvent paths for jQuery.ready()

    rwaldron authored
    Signed-off-by: Rick Waldron <waldron.rick@gmail.com>
  2. Rick Waldron

    Remove setTimeout for body existance

    rwaldron authored
    Signed-off-by: Rick Waldron <waldron.rick@gmail.com>
This page is out of date. Refresh to see the latest.
Showing with 3 additions and 49 deletions.
  1. +3 −49 src/core.js
52 src/core.js
View
@@ -72,15 +72,8 @@ var
// The ready event handler and self cleanup method
DOMContentLoaded = function() {
- if ( document.addEventListener ) {
- document.removeEventListener( "DOMContentLoaded", DOMContentLoaded, false );
- jQuery.ready();
- } else if ( document.readyState === "complete" ) {
- // we're here because readyState === "complete" in oldIE
- // which is good enough for us to call the dom ready!
- document.detachEvent( "onreadystatechange", DOMContentLoaded );
- jQuery.ready();
- }
+ document.removeEventListener( "DOMContentLoaded", DOMContentLoaded, false );
+ jQuery.ready();
};
jQuery.fn = jQuery.prototype = {
@@ -385,11 +378,6 @@ jQuery.extend({
return;
}
- // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
- if ( !document.body ) {
- return setTimeout( jQuery.ready );
- }
-
// Remember that the DOM is ready
jQuery.isReady = true;
@@ -862,46 +850,12 @@ jQuery.ready.promise = function( obj ) {
setTimeout( jQuery.ready );
// Standards-based browsers support DOMContentLoaded
- } else if ( document.addEventListener ) {
+ } else {
// Use the handy event callback
document.addEventListener( "DOMContentLoaded", DOMContentLoaded, false );
// A fallback to window.onload, that will always work
window.addEventListener( "load", jQuery.ready, false );
-
- // If IE event model is used
- } else {
- // Ensure firing before onload, maybe late but safe also for iframes
- document.attachEvent( "onreadystatechange", DOMContentLoaded );
-
- // A fallback to window.onload, that will always work
- window.attachEvent( "onload", jQuery.ready );
-
- // If IE and not a frame
- // continually check to see if the document is ready
- var top = false;
-
- try {
- top = window.frameElement == null && document.documentElement;
- } catch(e) {}
-
- if ( top && top.doScroll ) {
- (function doScrollCheck() {
- if ( !jQuery.isReady ) {
-
- try {
- // Use the trick by Diego Perini
- // http://javascript.nwbox.com/IEContentLoaded/
- top.doScroll("left");
- } catch(e) {
- return setTimeout( doScrollCheck, 50 );
- }
-
- // and execute any waiting functions
- jQuery.ready();
- }
- })();
- }
}
}
return readyList.promise( obj );
Something went wrong with that request. Please try again.