jquery core: closes #3541. Added isArray.
This commit is contained in:
parent
77cfd696ec
commit
325755d4b3
|
@ -76,7 +76,7 @@ jQuery.fn.extend({
|
||||||
.map(function(i, elem){
|
.map(function(i, elem){
|
||||||
var val = jQuery(this).val();
|
var val = jQuery(this).val();
|
||||||
return val == null ? null :
|
return val == null ? null :
|
||||||
val.constructor == Array ?
|
jQuery.isArray(val) ?
|
||||||
jQuery.map( val, function(val, i){
|
jQuery.map( val, function(val, i){
|
||||||
return {name: elem.name, value: val};
|
return {name: elem.name, value: val};
|
||||||
}) :
|
}) :
|
||||||
|
@ -504,7 +504,7 @@ jQuery.extend({
|
||||||
|
|
||||||
// If an array was passed in, assume that it is an array
|
// If an array was passed in, assume that it is an array
|
||||||
// of form elements
|
// of form elements
|
||||||
if ( a.constructor == Array || a.jquery )
|
if ( jQuery.isArray(a) || a.jquery )
|
||||||
// Serialize the form elements
|
// Serialize the form elements
|
||||||
jQuery.each( a, function(){
|
jQuery.each( a, function(){
|
||||||
add( this.name, this.value );
|
add( this.name, this.value );
|
||||||
|
@ -515,7 +515,7 @@ jQuery.extend({
|
||||||
// Serialize the key/values
|
// Serialize the key/values
|
||||||
for ( var j in a )
|
for ( var j in a )
|
||||||
// If the value is an array then the key names need to be repeated
|
// If the value is an array then the key names need to be repeated
|
||||||
if ( a[j] && a[j].constructor == Array )
|
if ( jQuery.isArray(a[j]) )
|
||||||
jQuery.each( a[j], function(){
|
jQuery.each( a[j], function(){
|
||||||
add( j, this );
|
add( j, this );
|
||||||
});
|
});
|
||||||
|
|
|
@ -407,7 +407,7 @@ jQuery.fn = jQuery.prototype = {
|
||||||
if ( this.nodeType != 1 )
|
if ( this.nodeType != 1 )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if ( value.constructor == Array && /radio|checkbox/.test( this.type ) )
|
if ( jQuery.isArray(value) && /radio|checkbox/.test( this.type ) )
|
||||||
this.checked = (jQuery.inArray(this.value, value) >= 0 ||
|
this.checked = (jQuery.inArray(this.value, value) >= 0 ||
|
||||||
jQuery.inArray(this.name, value) >= 0);
|
jQuery.inArray(this.name, value) >= 0);
|
||||||
|
|
||||||
|
@ -621,6 +621,10 @@ jQuery.extend({
|
||||||
isFunction: function( fn ) {
|
isFunction: function( fn ) {
|
||||||
return !!fn && !!fn.hasOwnProperty && fn instanceof Function;
|
return !!fn && !!fn.hasOwnProperty && fn instanceof Function;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
isArray: function( arr ){
|
||||||
|
return !!arr && arr.constructor == Array;
|
||||||
|
},
|
||||||
|
|
||||||
// check if an element is in a (or is an) XML document
|
// check if an element is in a (or is an) XML document
|
||||||
isXMLDoc: function( elem ) {
|
isXMLDoc: function( elem ) {
|
||||||
|
|
|
@ -112,7 +112,7 @@ jQuery.fn.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
queue: function(type, fn){
|
queue: function(type, fn){
|
||||||
if ( jQuery.isFunction(type) || ( type && type.constructor == Array )) {
|
if ( jQuery.isFunction(type) || jQuery.isArray(type) ) {
|
||||||
fn = type;
|
fn = type;
|
||||||
type = "fx";
|
type = "fx";
|
||||||
}
|
}
|
||||||
|
@ -121,7 +121,7 @@ jQuery.fn.extend({
|
||||||
return queue( this[0], type );
|
return queue( this[0], type );
|
||||||
|
|
||||||
return this.each(function(){
|
return this.each(function(){
|
||||||
if ( fn.constructor == Array )
|
if ( jQuery.isArray(fn) )
|
||||||
queue(this, type, fn);
|
queue(this, type, fn);
|
||||||
else {
|
else {
|
||||||
queue(this, type).push( fn );
|
queue(this, type).push( fn );
|
||||||
|
|
Loading…
Reference in a new issue