X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=src%2Fcore.js;h=2c2b7466622ab69cad829a27feecae4814d64147;hb=6dfdb14753c66cfd38f8445bd6119ef4a1274d5e;hp=23d40bd092d263bb425cfba9ab14a7825630faae;hpb=694b625c92c764621532dba20cbf943302b52d5a;p=jquery.git diff --git a/src/core.js b/src/core.js index 23d40bd..2c2b746 100644 --- a/src/core.js +++ b/src/core.js @@ -69,7 +69,10 @@ var jQuery = function( selector, context ) { push = Array.prototype.push, slice = Array.prototype.slice, trim = String.prototype.trim, - indexOf = Array.prototype.indexOf; + indexOf = Array.prototype.indexOf, + + // [[Class]] -> type pairs + class2type = {}; jQuery.fn = jQuery.prototype = { init: function( selector, context ) { @@ -434,7 +437,8 @@ jQuery.extend({ // Catch cases where $(document).ready() is called after the // browser event has already occurred. if ( document.readyState === "complete" ) { - return jQuery.ready(); + // Handle it asynchronously to allow scripts the opportunity to delay ready + return setTimeout( jQuery.ready, 13 ); } // Mozilla, Opera and webkit nightlies currently support this event @@ -487,7 +491,7 @@ jQuery.extend({ type: function( obj ) { return obj == null ? String( obj ) : - toString.call(obj).slice(8, -1).toLowerCase(); + class2type[ toString.call(obj) ] || "object"; }, isPlainObject: function( obj ) { @@ -799,6 +803,11 @@ jQuery.extend({ browser: {} }); +// Populate the class2type map +jQuery.each("Boolean Number String Function Array Date RegExp Object".split(" "), function(i, name) { + class2type[ "[object " + name + "]" ] = name.toLowerCase(); +}); + browserMatch = jQuery.uaMatch( userAgent ); if ( browserMatch.browser ) { jQuery.browser[ browserMatch.browser ] = true;