diff options
author | Richard Gibson <richard.gibson@gmail.com> | 2016-04-05 10:54:37 -0400 |
---|---|---|
committer | Richard Gibson <richard.gibson@gmail.com> | 2016-04-05 10:54:37 -0400 |
commit | 91850ecbbe04ad8f5d89dc050aa1d9002047c435 (patch) | |
tree | aaf13b402ef895b9e9e13c691a184c93ab0dd0c4 | |
parent | 9fdbdd393a0f0ebdcd837cf102878c8b45860c3b (diff) | |
download | jquery-91850ecbbe04ad8f5d89dc050aa1d9002047c435.tar.gz jquery-91850ecbbe04ad8f5d89dc050aa1d9002047c435.zip |
Serialize: Reduce size
Ref 9fdbdd393a0f0ebdcd837cf102878c8b45860c3b
-rw-r--r-- | src/serialize.js | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/serialize.js b/src/serialize.js index 9a735fec1..5f9d6c0ae 100644 --- a/src/serialize.js +++ b/src/serialize.js @@ -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. |