[jQuery] Patch against R:155 for ready() not working in Safari
Apparently my SVN access doesn't let me fix the main files. :)
Safari is being reported as mozilla, so I just reordered for the most
specific case on down.
I also put the window load binding in a else block, so that we're not
calling ready twice. (Maybe I'm missing something subtle here.)
Corey
Index: event/event.js
===================================================================
--- event/event.js (revision 155)
+++ event/event.js (working copy)
@@ -137,11 +137,23 @@
}
- // If Mozilla is used
- if ( jQuery.browser.mozilla || jQuery.browser.opera ) {
- // Use the handy event callback
- document.addEventListener( "DOMContentLoaded", jQuery.ready, false );
+ // If Safari is used
+ if ( jQuery.browser.safari ) {
+ // Continually check to see if the document.readyState is valid
+ jQuery.safariTimer = setInterval(function(){
+ // loaded and complete are both valid states
+ if ( document.readyState == "loaded" ||
+ document.readyState == "complete" ) {
+ // If either one are found, remove the timer
+ clearInterval( jQuery.safariTimer );
+ jQuery.safariTimer = null;
+
+ // and execute any waiting functions
+ jQuery.ready();
+ }
+ }, 10);
+
// If IE is used, use the excellent hack by Matthias Miller
// http://www.outofhanwell.com/blog/index.php?
title=the_window_onload_problem_revisited
} else if ( jQuery.browser.msie ) {
@@ -159,26 +171,13 @@
// Clear from memory
script = null;
-
- // If Safari is used
- } else if ( jQuery.browser.safari ) {
- // Continually check to see if the document.readyState is valid
- jQuery.safariTimer = setInterval(function(){
- // loaded and complete are both valid states
- if ( document.readyState == "loaded" ||
- document.readyState == "complete" ) {
-
- // If either one are found, remove the timer
- clearInterval( jQuery.safariTimer );
- jQuery.safariTimer = null;
-
- // and execute any waiting functions
- jQuery.ready();
- }
- }, 10);
- }
-
- // A fallback to window.onload, that will always work
- jQuery.event.add( window, "load", jQuery.ready );
-
+
+ // If Mozilla is used
+ } else if ( jQuery.browser.mozilla || jQuery.browser.opera ) {
+ // Use the handy event callback
+ document.addEventListener( "DOMContentLoaded", jQuery.ready, false );
+ } else {
+ // A fallback to window.onload, that will always work
+ jQuery.event.add( window, "load", jQuery.ready );
+ }
}
_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/