-
Notifications
You must be signed in to change notification settings - Fork 20.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ref 9fdbdd3
- Loading branch information
Showing
1 changed file
with
8 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 ); | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
mgol
Member
|
||
}; | ||
|
||
// Set traditional to true for jQuery <= 1.3.2 behavior. | ||
|
1 comment
on commit 91850ec
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I kinda like the new solution
(value == null ? "" : encodeURIComponent( value )); wouldn't be better?