Skip to main content

Bug Tracker

Side navigation

Ticket #1319: 1319.diff


File 1319.diff, 1.5 KB (added by davidserduke, December 19, 2007 08:54PM UTC)

patch

Index: src/event.js
===================================================================
--- src/event.js	(revision 4241)
+++ src/event.js	(working copy)
@@ -496,20 +496,38 @@
 	
 	// If Safari or IE is used
 	// Continually check to see if the document is ready
-	if (jQuery.browser.msie || jQuery.browser.safari ) (function(){
+	if ( jQuery.browser.msie ) (function(){
 		try {
 			// If IE is used, use the trick by Diego Perini
 			// http://javascript.nwbox.com/IEContentLoaded/
-			if ( jQuery.browser.msie || document.readyState != "loaded" && document.readyState != "complete" )
-				document.documentElement.doScroll("left");
+			document.documentElement.doScroll("left");
 		} catch( error ) {
-			return setTimeout( arguments.callee, 0 );
+			setTimeout( arguments.callee, 0 );
+			return;
 		}
-
 		// and execute any waiting functions
 		jQuery.ready();
 	})();
 
+	if ( jQuery.browser.safari ) {
+		var numStyles;
+		(function(){
+			 if ( document.readyState != "loaded" && document.readyState != "complete" ) {
+				setTimeout( arguments.callee, 0 );
+				return;
+			}
+			if ( numStyles === undefined )
+				numStyles = jQuery("style, link[rel=stylesheet]").length;
+			if ( document.styleSheets.length != numStyles ) {
+				setTimeout( arguments.callee, 0 );
+				return;
+			}
+
+			// and execute any waiting functions
+			jQuery.ready();
+		})();
+	}
+
 	// A fallback to window.onload, that will always work
 	jQuery.event.add( window, "load", jQuery.ready );
 }

Download in other formats:

Original Format