summaryrefslogtreecommitdiffstats
path: root/js/vendor/jquery/src/serialize.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/vendor/jquery/src/serialize.js')
-rw-r--r--js/vendor/jquery/src/serialize.js42
1 files changed, 28 insertions, 14 deletions
diff --git a/js/vendor/jquery/src/serialize.js b/js/vendor/jquery/src/serialize.js
index 0d6dfec6d..94698fc2f 100644
--- a/js/vendor/jquery/src/serialize.js
+++ b/js/vendor/jquery/src/serialize.js
@@ -1,4 +1,4 @@
-define([
+define( [
"./core",
"./manipulation/var/rcheckableType",
"./core/init",
@@ -16,25 +16,35 @@ function buildParams( prefix, obj, traditional, add ) {
var name;
if ( jQuery.isArray( obj ) ) {
+
// Serialize array item.
jQuery.each( obj, function( i, v ) {
if ( traditional || rbracket.test( prefix ) ) {
+
// Treat each array item as a scalar.
add( prefix, v );
} else {
+
// Item is non-scalar (array or object), encode its numeric index.
- buildParams( prefix + "[" + ( typeof v === "object" ? i : "" ) + "]", v, traditional, add );
+ buildParams(
+ prefix + "[" + ( typeof v === "object" && v != null ? i : "" ) + "]",
+ v,
+ traditional,
+ add
+ );
}
- });
+ } );
} else if ( !traditional && jQuery.type( obj ) === "object" ) {
+
// Serialize object item.
for ( name in obj ) {
buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add );
}
} else {
+
// Serialize scalar item.
add( prefix, obj );
}
@@ -46,6 +56,7 @@ jQuery.param = function( a, traditional ) {
var prefix,
s = [],
add = function( key, value ) {
+
// If value is a function, invoke it and return its value
value = jQuery.isFunction( value ) ? value() : ( value == null ? "" : value );
s[ s.length ] = encodeURIComponent( key ) + "=" + encodeURIComponent( value );
@@ -58,12 +69,14 @@ jQuery.param = function( a, traditional ) {
// If an array was passed in, assume that it is an array of form elements.
if ( jQuery.isArray( a ) || ( a.jquery && !jQuery.isPlainObject( a ) ) ) {
+
// Serialize the form elements
jQuery.each( a, function() {
add( this.name, this.value );
- });
+ } );
} else {
+
// If traditional, encode the "old" way (the way 1.3.2 or older
// did it), otherwise encode params recursively.
for ( prefix in a ) {
@@ -75,25 +88,26 @@ jQuery.param = function( a, traditional ) {
return s.join( "&" ).replace( r20, "+" );
};
-jQuery.fn.extend({
+jQuery.fn.extend( {
serialize: function() {
return jQuery.param( this.serializeArray() );
},
serializeArray: function() {
- return this.map(function() {
+ return this.map( function() {
+
// Can add propHook for "elements" to filter or add form elements
var elements = jQuery.prop( this, "elements" );
return elements ? jQuery.makeArray( elements ) : this;
- })
- .filter(function() {
+ } )
+ .filter( function() {
var type = this.type;
// Use .is( ":disabled" ) so that fieldset[disabled] works
return this.name && !jQuery( this ).is( ":disabled" ) &&
rsubmittable.test( this.nodeName ) && !rsubmitterTypes.test( type ) &&
( this.checked || !rcheckableType.test( type ) );
- })
- .map(function( i, elem ) {
+ } )
+ .map( function( i, elem ) {
var val = jQuery( this ).val();
return val == null ?
@@ -101,11 +115,11 @@ jQuery.fn.extend({
jQuery.isArray( val ) ?
jQuery.map( val, function( val ) {
return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
- }) :
+ } ) :
{ name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
- }).get();
+ } ).get();
}
-});
+} );
return jQuery;
-});
+} );