$.param(undefined) - throws Cannot read property 'jquery' of undefined #2633
Comments
|
Thanks for the report.
We've recently made |
|
Thanks, yeah I figured it's more of a "nice to have" feature, just wanted to get it out there just incase no one ran into it! |
|
This is really easy to fix on the caller's side though. If you know the value may be undefined, use the |
|
@dmethvin You could say the same about |
|
I agree. If those weren't regressions (in undocumented behavior) I don't think we would have changed them. Or at least I wouldn't have been in favor of it. |
|
I'd tend to think consistency trumps history in the matter and I'd be in favor of gracefully handling the nul/undefined case. |
|
So is the suggestion to handle just |
|
I'm fine with having this ticket just about handling
$.param(null|undefined). We can wait for bug reports before thinking about
other ones.
|
|
Should we treat it as a breaking change or a new feature? In the latter case this could be moved to |
|
Definitely a feature, since we're talking about expanding the signature. |
|
OK, milestone |
|
(Hopefully not too far off topic) Since a change is being considered to handle $.param(function(){
var params = {};
// Build params
return params;
}); |
|
I'm not a fan of adding more behavior to this API (and documenting it, don't forget). Unfortunately I suppose we've already crossed the Rubicon by calling functions at all, which prevent |
|
@dmethvin I moved this question to separate issue. |
Using jQuery 1.11.3 in Chrome, I'm not sure if this is a bug or a "nice to have feature", but if you try to do a
$.param()on somethingundefinedit throws the error:This mainly happens when let's say your passing parameters into a function and sometimes you don't want/need to pass any:
The easiest fix is to simply:
The text was updated successfully, but these errors were encountered: