-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUGFIX beta] Improve behavior for QPs with undefined values #14537
Conversation
People willing to make hard decisions: can we take this a step further? I'd like to force all values passed into _serializeQueryParams(handlerInfos, queryParams) {
queryParams = JSON.parse(JSON.serialize(queryParams));
// ... This makes it possible for people to either pass arbitrary objects which implement It also neatly sidesteps this issue: JSON.parse(JSON.stringify({foo:undefined}));
// => {}
JSON.parse(JSON.stringify({foo:null}));
// => { foo: null } Thoughts? |
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.
Looks good to me, with one small nit-pick...
@@ -669,7 +669,7 @@ const EmberRouter = EmberObject.extend(Evented, { | |||
if (qp) { | |||
delete queryParams[key]; | |||
queryParams[qp.urlKey] = qp.route.serializeQueryParam(value, qp.urlKey, qp.type); | |||
} else { | |||
} else if (value !== undefined) { |
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.
Super not-picky but I'd rather leave this as an unconditional else clause. Could you swap this to check if it's undefined and just noop (as an else if before the final else)?
@nathanhammond - Let's keep that separate from this PR, but generally I think it could work (generally speaking). Happy to review a PR (or general sketch of the logic). |
b024059
to
6184e6f
Compare
@rwjblue updated, but getting a linting error. Should I just return from the block? |
6184e6f
to
098300d
Compare
Thanks @trentmwillis! |
For the case of lazy loading Engines, all QPs get serialized into the URL initially.
undefined
shouldn't get serialized to a string, so that when it gets pulled out the value is not a string.cc @nathanhammond