Skip to content

Deeply nested objects in query are considered equal when they are not really equal #1421

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

Closed
awei01 opened this issue May 16, 2017 · 2 comments
Assignees

Comments

@awei01
Copy link

awei01 commented May 16, 2017

Version

2.5.3

Reproduction link

https://jsfiddle.net/awei01/5v9nqe7o/

Steps to reproduce

Open the JS fiddle.
Open console logger
Click the link, notice that the query is updated and console logs "route completed"
Click link again. Notice the query is not updated and console logs "route aborted"

What is expected?

The route should change because the query object has changed.

What is actually happening?

The route inspector should see that these objects are not equal. The implementation of "isEqualObject" doesn't take into account deeply nested objects.

see these lines:

function isObjectEqual (a = {}, b = {}): boolean {
const aKeys = Object.keys(a)
const bKeys = Object.keys(b)
if (aKeys.length !== bKeys.length) {
return false
}
return aKeys.every(key => String(a[key]) === String(b[key]))
}


I'm using my own custom implementation of parseQuery and stringifyQuery for the Router object so, I'd like to be able to allow the route to continue. Specifically I'm using 'urlon' npm package which can handle nested objects in the querystring.

@posva
Copy link
Member

posva commented May 16, 2017

I'm using my own custom implementation of parseQuery and stringifyQuery for the Router object so, I'd like to be able to allow the route to continue. Specifically I'm using 'urlon' npm package which can handle nested objects in the querystring.

That's interesting, did you patch the code or actually implemented a way of using any library like qs?

For the moment, nested queries are not supported (the url will look something like [object Object] but escaped), but this is indeed something that must be improved once we support other implementations of those functions. I'll give it a look tomorrow 🙂

edit: Somehow I missed that we already support that. I feel so dumb 😓

@awei01
Copy link
Author

awei01 commented May 17, 2017

@posva No worries. Yes, I did use the recently added parseQuery and stringifyQuery configuration keys.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants