jquery core: reverted qunit introduction until build scripts are updated
[jquery.git] / src / core.js
index fbf9f99..a6d4c5f 100644 (file)
@@ -140,12 +140,10 @@ jQuery.fn = jQuery.prototype = {
                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 ) {
@@ -339,12 +337,12 @@ jQuery.fn = jQuery.prototype = {
        },
 
        add: function( selector ) {
-               return !selector ? this : this.pushStack( jQuery.merge( 
+               return this.pushStack( jQuery.unique( jQuery.merge( 
                        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 ) {
@@ -1109,14 +1107,14 @@ jQuery.extend({
        makeArray: function( array ) {
                var ret = [];
 
-               if( array != undefined ){
+               if( array != null ){
                        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];
-                       else
-                               ret[0] = array;
                }
 
                return ret;
@@ -1124,7 +1122,8 @@ jQuery.extend({
 
        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;