git.asbjorn.biz
/
jquery.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fixes #7229 and #5803
[jquery.git]
/
src
/
core.js
diff --git
a/src/core.js
b/src/core.js
index
b747e5b
..
3a37c4a
100644
(file)
--- 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 non-word characters
rnonword = /\W/,
+ // Check for digits
+ rdigit = /\d/,
+
// Match a standalone tag
rsingleTag = /^<(\w+)\s*\/?>(?:<\/\1>)?$/,
// Match a standalone tag
rsingleTag = /^<(\w+)\s*\/?>(?:<\/\1>)?$/,
@@
-69,7
+72,10
@@
var jQuery = function( selector, context ) {
push = Array.prototype.push,
slice = Array.prototype.slice,
trim = String.prototype.trim,
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 ) {
jQuery.fn = jQuery.prototype = {
init: function( selector, context ) {
@@
-88,7
+94,7
@@
jQuery.fn = jQuery.prototype = {
}
// The body element only exists once, optimize finding it
}
// 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";
this.context = document;
this[0] = document.body;
this.selector = "body";
@@
-306,7
+312,7
@@
jQuery.fn.init.prototype = jQuery.fn;
jQuery.extend = jQuery.fn.extend = function() {
// copy reference to target object
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;
+ var target = arguments[0] || {}, i = 1, length = arguments.length, deep = false, options, name, src, copy, copyIsArray, clone;
// Handle a deep copy situation
if ( typeof target === "boolean" ) {
// Handle a deep copy situation
if ( typeof target === "boolean" ) {
@@
-340,10
+346,15
@@
jQuery.extend = jQuery.fn.extend = function() {
continue;
}
continue;
}
- // Recurse if we're merging object literal values or arrays
- if ( deep && copy && ( jQuery.isPlainObject(copy) || jQuery.isArray(copy) ) ) {
- var clone = src && ( jQuery.isPlainObject(src) || jQuery.isArray(src) ) ? src
- : jQuery.isArray(copy) ? [] : {};
+ // Recurse if we're merging plain objects or arrays
+ if ( deep && copy && ( jQuery.isPlainObject(copy) || (copyIsArray = jQuery.isArray(copy)) ) ) {
+ if ( copyIsArray ) {
+ copyIsArray = false;
+ clone = src && jQuery.isArray(src) ? src : [];
+
+ } else {
+ clone = src && jQuery.isPlainObject(src) ? src : {};
+ }
// Never move original objects, clone them
target[ name ] = jQuery.extend( deep, clone, copy );
// Never move original objects, clone them
target[ name ] = jQuery.extend( deep, clone, copy );
@@
-389,7
+400,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 ) {
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
}
// Remember that the DOM is ready
@@
-413,8
+424,8
@@
jQuery.extend({
}
// Trigger any bound ready events
}
// Trigger any bound ready events
- if ( jQuery.fn.triggerHandler ) {
- jQuery( document ).triggerHandler( "ready" );
+ if ( jQuery.fn.trigger ) {
+ jQuery( document ).trigger( "ready" ).unbind( "ready" );
}
}
},
}
}
},
@@
-429,7
+440,8
@@
jQuery.extend({
// Catch cases where $(document).ready() is called after the
// browser event has already occurred.
if ( document.readyState === "complete" ) {
// 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, 1 );
}
// Mozilla, Opera and webkit nightlies currently support this event
}
// Mozilla, Opera and webkit nightlies currently support this event
@@
-479,10
+491,14
@@
jQuery.extend({
return obj && typeof obj === "object" && "setInterval" in obj;
},
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 ) :
type: function( obj ) {
return obj == null ?
String( obj ) :
- toString.call(obj).slice(8, -1).toLowerCase();
+ class2type[ toString.call(obj) ] || "object";
},
isPlainObject: function( obj ) {
},
isPlainObject: function( obj ) {
@@
-794,6
+810,11
@@
jQuery.extend({
browser: {}
});
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;
browserMatch = jQuery.uaMatch( userAgent );
if ( browserMatch.browser ) {
jQuery.browser[ browserMatch.browser ] = true;