]> source.dussan.org Git - jquery.git/commitdiff
Serialize: Reduce size
authorRichard Gibson <richard.gibson@gmail.com>
Tue, 5 Apr 2016 14:54:37 +0000 (10:54 -0400)
committerRichard Gibson <richard.gibson@gmail.com>
Tue, 5 Apr 2016 14:54:37 +0000 (10:54 -0400)
Ref 9fdbdd393a0f0ebdcd837cf102878c8b45860c3b

src/serialize.js

index 9a735fec18c730afbf3ea39f816e612ae1ac73eb..5f9d6c0ae40f74fc282c98139925b47f6ed51b14 100644 (file)
@@ -55,14 +55,15 @@ function buildParams( prefix, obj, traditional, add ) {
 jQuery.param = function( a, traditional ) {
        var prefix,
                s = [],
-               add = function( key, value ) {
+               add = function( key, valueOrFunction ) {
 
-                       // If value is a function, invoke it and return its value
-                       value = jQuery.isFunction( value ) ? value() : value;
-                       if ( value == null ) {
-                               value = "";
-                       }
-                       s[ s.length ] = encodeURIComponent( key ) + "=" + encodeURIComponent( value );
+                       // If value is a function, invoke it and use its return value
+                       var value = jQuery.isFunction( valueOrFunction ) ?
+                               valueOrFunction() :
+                               valueOrFunction;
+
+                       s[ s.length ] = encodeURIComponent( key ) + "=" +
+                               encodeURIComponent( value == null ? "" : value );
                };
 
        // Set traditional to true for jQuery <= 1.3.2 behavior.