X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=src%2Fcore.js;h=158f47998ef137564de8ccc059c1b0c7884bb23c;hb=484cc6e22000aaa6cefab5752b165f6ebd62ffe1;hp=23d40bd092d263bb425cfba9ab14a7825630faae;hpb=7367b524ec6c7cda0a4146e50a5dc6d7764bdef7;p=jquery.git diff --git a/src/core.js b/src/core.js index 23d40bd..158f479 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 ) { @@ -487,7 +490,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 +802,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;