git.asbjorn.biz
/
jquery.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
jquery fx & event: replaced the use of .apply(), where .call() could had been used.
[jquery.git]
/
src
/
core.js
diff --git
a/src/core.js
b/src/core.js
index
fbf9f99
..
a86ef8d
100644
(file)
--- a/
src/core.js
+++ b/
src/core.js
@@
-24,7
+24,10
@@
var jQuery = window.jQuery = window.$ = function( selector, context ) {
var quickExpr = /^[^<]*(<(.|\s)+>)[^>]*$|^#(\w+)$/,
// Is it a simple selector
var quickExpr = /^[^<]*(<(.|\s)+>)[^>]*$|^#(\w+)$/,
// Is it a simple selector
- isSimple = /^.[^:#\[\.]*$/;
+ isSimple = /^.[^:#\[\.]*$/,
+
+// Will speed up references to undefined, and allows munging its name.
+ undefined;
jQuery.fn = jQuery.prototype = {
init: function( selector, context ) {
jQuery.fn = jQuery.prototype = {
init: function( selector, context ) {
@@
-140,12
+143,10
@@
jQuery.fn = jQuery.prototype = {
var ret = -1;
// Locate the position of the desired element
var ret = -1;
// Locate the position of the desired element
- this.each(function(i){
- if ( this == elem )
- ret = i;
- });
-
- return ret;
+ return jQuery.inArray(
+ // If it receives a jQuery object, the first element is used
+ elem && elem.jquery ? elem[0] : elem
+ , this );
},
attr: function( name, value, type ) {
},
attr: function( name, value, type ) {
@@
-339,12
+340,12
@@
jQuery.fn = jQuery.prototype = {
},
add: function( selector ) {
},
add: function( selector ) {
- return !selector ? this : this.pushStack( jQuery.merge(
+ return this.pushStack( jQuery.unique( jQuery.merge(
this.get(),
this.get(),
- selector.constructor == String ?
- jQuery( selector ).get() :
- selector.length != undefined && (!selector.nodeName || jQuery.nodeName(selector, "form")) ?
- selector : [selector] ) );
+ typeof selector == 'string' ?
+ jQuery( selector ) :
+ jQuery.makeArray( selector )
+ )));
},
is: function( selector ) {
},
is: function( selector ) {
@@
-1109,14
+1110,14
@@
jQuery.extend({
makeArray: function( array ) {
var ret = [];
makeArray: function( array ) {
var ret = [];
- if( array != undefined ){
+ if( array != null ){
var i = array.length;
//the window, strings and functions also have 'length'
var i = array.length;
//the window, strings and functions also have 'length'
- if( i != null && !array.split && array != window && !array.call )
+ if( i == null || array.split || array.setInterval || array.call )
+ ret[0] = array;
+ else
while( i )
ret[--i] = array[i];
while( i )
ret[--i] = array[i];
- else
- ret[0] = array;
}
return ret;
}
return ret;
@@
-1124,7
+1125,8
@@
jQuery.extend({
inArray: function( elem, array ) {
for ( var i = 0, length = array.length; i < length; i++ )
inArray: function( elem, array ) {
for ( var i = 0, length = array.length; i < length; i++ )
- if ( array[ i ] == elem )
+ // Use === because on IE, window == document
+ if ( array[ i ] === elem )
return i;
return -1;
return i;
return -1;
@@
-1175,7
+1177,7
@@
jQuery.extend({
// Go through the array, only saving the items
// that pass the validator function
for ( var i = 0, length = elems.length; i < length; i++ )
// Go through the array, only saving the items
// that pass the validator function
for ( var i = 0, length = elems.length; i < length; i++ )
- if ( !inv && callback( elems[ i ], i ) || inv && !callback( elems[ i ], i ) )
+ if ( !inv != !callback( elems[ i ], i ) )
ret.push( elems[ i ] );
return ret;
ret.push( elems[ i ] );
return ret;