Fix up whitespace and a couple of glitches.
[jquery.git] / src / core.js
index 26f6e92..5f1bc3a 100644 (file)
@@ -1,9 +1,7 @@
 // Define a local copy of jQuery
 var jQuery = function( selector, context ) {
                // The jQuery object is actually just the init constructor 'enhanced'
-               return arguments.length === 0 ?
-                       rootjQuery :
-                       new jQuery.fn.init( selector, context );
+               return new jQuery.fn.init( selector, context );
        },
 
        // Map over jQuery in case of overwrite
@@ -237,7 +235,7 @@ jQuery.fn = jQuery.prototype = {
                jQuery.bindReady();
 
                // If the DOM is already ready
-               if ( jQuery.isReady ) {
+               if ( jQuery.isReady && !readyList ) {
                        // Execute the function immediately
                        fn.call( document, jQuery );
 
@@ -373,8 +371,8 @@ jQuery.extend({
                // Mozilla, Opera and webkit nightlies currently support this event
                if ( document.addEventListener ) {
                        // Use the handy event callback
-                       document.addEventListener( "DOMContentLoaded", function() {
-                               document.removeEventListener( "DOMContentLoaded", arguments.callee, false );
+                       document.addEventListener( "DOMContentLoaded", function DOMContentLoaded() {
+                               document.removeEventListener( "DOMContentLoaded", DOMContentLoaded, false );
                                jQuery.ready();
                        }, false );
                        
@@ -385,10 +383,10 @@ jQuery.extend({
                } else if ( document.attachEvent ) {
                        // ensure firing before onload,
                        // maybe late but safe also for iframes
-                       document.attachEvent("onreadystatechange", function() {
+                       document.attachEvent("onreadystatechange", function onreadystatechange() {
                                // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
                                if ( document.readyState === "complete" ) {
-                                       document.detachEvent( "onreadystatechange", arguments.callee );
+                                       document.detachEvent( "onreadystatechange", onreadystatechange );
                                        jQuery.ready();
                                }
                        });
@@ -405,7 +403,9 @@ jQuery.extend({
                        } catch(e){}
 
                        if ( document.documentElement.doScroll && toplevel ) {
-                               (function() {
+                               doScrollCheck();
+
+                               function doScrollCheck() {
                                        if ( jQuery.isReady ) {
                                                return;
                                        }
@@ -415,13 +415,13 @@ jQuery.extend({
                                                // http://javascript.nwbox.com/IEContentLoaded/
                                                document.documentElement.doScroll("left");
                                        } catch( error ) {
-                                               setTimeout( arguments.callee, 0 );
+                                               setTimeout( doScrollCheck, 1 );
                                                return;
                                        }
 
                                        // and execute any waiting functions
                                        jQuery.ready();
-                               })();
+                               }
                        }
                }
        },
@@ -444,8 +444,8 @@ jQuery.extend({
                
                // not own constructor property must be Object
                if ( obj.constructor
-                 && !hasOwnProperty.call(obj, "constructor")
-                 && !hasOwnProperty.call(obj.constructor.prototype, "isPrototypeOf") ) {
+                       && !hasOwnProperty.call(obj, "constructor")
+                       && !hasOwnProperty.call(obj.constructor.prototype, "isPrototypeOf") ) {
                        return false;
                }
                
@@ -481,7 +481,7 @@ jQuery.extend({
                                script.text = data;
                        }
 
-                       // Use insertBefore instead of appendChild  to circumvent an IE6 bug.
+                       // Use insertBefore instead of appendChild to circumvent an IE6 bug.
                        // This arises when a base node is used (#2709).
                        head.insertBefore( script, head.firstChild );
                        head.removeChild( script );
@@ -618,18 +618,20 @@ jQuery.extend({
                return ret.concat.apply( [], ret );
        },
 
-       // Use of jQuery.browser is deprecated.
-       // It's included for backwards compatibility and plugins,
-       // although they should work to migrate away.
+       // Use of jQuery.browser is frowned upon.
+       // More details: http://docs.jquery.com/Utilities/jQuery.browser
        browser: {
-               version: (/.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/.exec(userAgent) || [0,'0'])[1],
-               safari: /webkit/.test( userAgent ),
+               version: (/.*?(?:firefox|safari|opera|msie)[\/ ]([\d.]+)/.exec(userAgent) || [0,'0'])[1],
+               safari: /safari/.test( userAgent ),
                opera: /opera/.test( userAgent ),
                msie: /msie/.test( userAgent ) && !/opera/.test( userAgent ),
-               mozilla: /mozilla/.test( userAgent ) && !/(compatible|webkit)/.test( userAgent )
+               firefox: /firefox/.test( userAgent )
        }
 });
 
+// Deprecated
+jQuery.browser.mozilla = /mozilla/.test( userAgent ) && !/(compatible|webkit)/.test( userAgent );
+
 if ( indexOf ) {
        jQuery.inArray = function( elem, array ) {
                return indexOf.call( array, elem );