git.asbjorn.biz
/
jquery.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Make sure that &#...; entities are encoded properly. Fixes #6042.
[jquery.git]
/
src
/
core.js
diff --git
a/src/core.js
b/src/core.js
index
5c99068
..
34bab95
100644
(file)
--- a/
src/core.js
+++ b/
src/core.js
@@
-69,6
+69,15
@@
jQuery.fn = jQuery.prototype = {
this.length = 1;
return this;
}
this.length = 1;
return this;
}
+
+ // The body element only exists once, optimize finding it
+ if ( selector === "body" && !context ) {
+ this.context = document;
+ this[0] = document.body;
+ this.selector = "body";
+ this.length = 1;
+ return this;
+ }
// Handle HTML strings
if ( typeof selector === "string" ) {
// Handle HTML strings
if ( typeof selector === "string" ) {
@@
-99,7
+108,9
@@
jQuery.fn = jQuery.prototype = {
ret = buildFragment( [ match[1] ], [ doc ] );
selector = (ret.cacheable ? ret.fragment.cloneNode(true) : ret.fragment).childNodes;
}
ret = buildFragment( [ match[1] ], [ doc ] );
selector = (ret.cacheable ? ret.fragment.cloneNode(true) : ret.fragment).childNodes;
}
-
+
+ return jQuery.merge( this, selector );
+
// HANDLE: $("#id")
} else {
elem = document.getElementById( match[2] );
// HANDLE: $("#id")
} else {
elem = document.getElementById( match[2] );
@@
-126,6
+137,7
@@
jQuery.fn = jQuery.prototype = {
this.selector = selector;
this.context = document;
selector = document.getElementsByTagName( selector );
this.selector = selector;
this.context = document;
selector = document.getElementsByTagName( selector );
+ return jQuery.merge( this, selector );
// HANDLE: $(expr, $(...))
} else if ( !context || context.jquery ) {
// HANDLE: $(expr, $(...))
} else if ( !context || context.jquery ) {
@@
-148,9
+160,7
@@
jQuery.fn = jQuery.prototype = {
this.context = selector.context;
}
this.context = selector.context;
}
- return jQuery.isArray( selector ) ?
- this.setArray( selector ) :
- jQuery.makeArray( selector, this );
+ return jQuery.makeArray( selector, this );
},
// Start with an empty selector
},
// Start with an empty selector
@@
-472,25
+482,24
@@
jQuery.extend({
},
parseJSON: function( data ) {
},
parseJSON: function( data ) {
+ if ( typeof data !== "string" || !data ) {
+ return null;
+ }
+
// Make sure the incoming data is actual JSON
// Logic borrowed from http://json.org/json2.js
// Make sure the incoming data is actual JSON
// Logic borrowed from http://json.org/json2.js
- if (/^[\],:{}\s]*$/.test(data.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, "@")
+ if ( /^[\],:{}\s]*$/.test(data.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, "@")
.replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, "]")
.replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, "]")
- .replace(/(?:^|:|,)(?:\s*\[)+/g, ""))) {
+ .replace(/(?:^|:|,)(?:\s*\[)+/g, "")) ) {
// Try to use the native JSON parser first
// Try to use the native JSON parser first
- if ( window.JSON && window.JSON.parse ) {
- data = window.JSON.parse( data );
-
- } else {
- data = (new Function("return " + data))();
- }
+ return window.JSON && window.JSON.parse ?
+ window.JSON.parse( data ) :
+ (new Function("return " + data))();
} else {
jQuery.error( "Invalid JSON: " + data );
}
} else {
jQuery.error( "Invalid JSON: " + data );
}
-
- return data;
},
noop: function() {},
},
noop: function() {},
@@
-603,6
+612,7
@@
jQuery.extend({
for ( var l = second.length; j < l; j++ ) {
first[ i++ ] = second[ j ];
}
for ( var l = second.length; j < l; j++ ) {
first[ i++ ] = second[ j ];
}
+
} else {
while ( second[j] !== undefined ) {
first[ i++ ] = second[ j++ ];
} else {
while ( second[j] !== undefined ) {
first[ i++ ] = second[ j++ ];