X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=src%2Fcore.js;h=4da1212c1491488a10548c476a7e03e61d78b50c;hb=9029dc02a234ad9699513f81acd1423f9c2c4e30;hp=2c2b7466622ab69cad829a27feecae4814d64147;hpb=6dfdb14753c66cfd38f8445bd6119ef4a1274d5e;p=jquery.git diff --git a/src/core.js b/src/core.js index 2c2b746..4da1212 100644 --- a/src/core.js +++ b/src/core.js @@ -33,6 +33,9 @@ var jQuery = function( selector, context ) { // Check for non-word characters rnonword = /\W/, + // Check for digits + rdigit = /\d/, + // Match a standalone tag rsingleTag = /^<(\w+)\s*\/?>(?:<\/\1>)?$/, @@ -91,7 +94,7 @@ jQuery.fn = jQuery.prototype = { } // The body element only exists once, optimize finding it - if ( selector === "body" && !context ) { + if ( selector === "body" && !context && document.body ) { this.context = document; this[0] = document.body; this.selector = "body"; @@ -212,7 +215,7 @@ jQuery.fn = jQuery.prototype = { this.toArray() : // Return just the object - ( num < 0 ? this.slice(num)[ 0 ] : this[ num ] ); + ( num < 0 ? this[ this.length + num ] : this[ num ] ); }, // Take an array of elements and push it onto the stack @@ -308,8 +311,11 @@ jQuery.fn = jQuery.prototype = { jQuery.fn.init.prototype = jQuery.fn; jQuery.extend = jQuery.fn.extend = function() { - // copy reference to target object - var target = arguments[0] || {}, i = 1, length = arguments.length, deep = false, options, name, src, copy, copyIsArray; + var options, name, src, copy, copyIsArray, clone, + target = arguments[0] || {}, + i = 1, + length = arguments.length, + deep = false; // Handle a deep copy situation if ( typeof target === "boolean" ) { @@ -397,7 +403,7 @@ jQuery.extend({ if ( !jQuery.readyWait || (wait !== true && !jQuery.isReady) ) { // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443). if ( !document.body ) { - return setTimeout( jQuery.ready, 13 ); + return setTimeout( jQuery.ready, 1 ); } // Remember that the DOM is ready @@ -411,18 +417,21 @@ jQuery.extend({ // If there are functions bound, to execute if ( readyList ) { // Execute all of them - var fn, i = 0; - while ( (fn = readyList[ i++ ]) ) { - fn.call( document, jQuery ); - } + var fn, + i = 0, + ready = readyList; // Reset the list of functions readyList = null; - } - // Trigger any bound ready events - if ( jQuery.fn.triggerHandler ) { - jQuery( document ).triggerHandler( "ready" ); + while ( (fn = ready[ i++ ]) ) { + fn.call( document, jQuery ); + } + + // Trigger any bound ready events + if ( jQuery.fn.trigger ) { + jQuery( document ).trigger( "ready" ).unbind( "ready" ); + } } } }, @@ -438,7 +447,7 @@ jQuery.extend({ // browser event has already occurred. if ( document.readyState === "complete" ) { // Handle it asynchronously to allow scripts the opportunity to delay ready - return setTimeout( jQuery.ready, 13 ); + return setTimeout( jQuery.ready, 1 ); } // Mozilla, Opera and webkit nightlies currently support this event @@ -488,6 +497,10 @@ jQuery.extend({ return obj && typeof obj === "object" && "setInterval" in obj; }, + isNaN: function( obj ) { + return obj == null || !rdigit.test( obj ) || isNaN( obj ); + }, + type: function( obj ) { return obj == null ? String( obj ) : @@ -671,7 +684,8 @@ jQuery.extend({ }, merge: function( first, second ) { - var i = first.length, j = 0; + var i = first.length, + j = 0; if ( typeof second.length === "number" ) { for ( var l = second.length; j < l; j++ ) { @@ -719,6 +733,7 @@ jQuery.extend({ } } + // Flatten any nested arrays return ret.concat.apply( [], ret ); }, @@ -871,6 +886,11 @@ function doScrollCheck() { jQuery.ready(); } +// Expose jQuery as an Asynchronous Module +if ( typeof define === "function" ) { + define( "jquery", [], function () { return jQuery; } ); +} + // Expose jQuery to the global object return (window.jQuery = window.$ = jQuery);