Skip to content

This PR addresses issue #831, adding public Router#resolve method #877

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
wants to merge 13 commits into from
Closed

Conversation

hogart
Copy link
Contributor

@hogart hogart commented Nov 4, 2016

Along with necessary typings and docs.

From technical perspective this change adds protected _resolve and public resolve methods, latter being wrapper around first. _resolve is used in <router-link/>, since it requires a lot of additional info. resolve just returns relevant bits from that.

Function createHref was moved to src/index.js, but maybe belongs in sc/util/path.js.

@posva
Copy link
Member

posva commented Nov 5, 2016

Thanks for the pr!
I'd rather have a single resolve method. Let's wait for @fnlctrl and @yyx990803 input

const fullPath = resolved.redirectedFrom || resolved.fullPath
const base = router.history.base
const href = createHref(base, fullPath, router.mode)
const { normalizedTo, resolved, href } = this.$router._resolve(this.to, current, this.append)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can directly call router._resolve

@hogart
Copy link
Contributor Author

hogart commented Nov 5, 2016

I'd rather have a single resolve method.

Me too. We can rename that internal method, I think.

@LinusBorg
Copy link
Member

I like this PR. @hogart, Can you solve the conflicts?

@hogart
Copy link
Contributor Author

hogart commented Nov 15, 2016

Thanks, @LinusBorg. I merged my branch with upstream.

@LinusBorg
Copy link
Member

LinusBorg commented Nov 18, 2016

@hogart sorry to bother again. This also needs a a unnit test for the new #resolve() function. Could you add one?

@fnlctrl
Copy link
Member

fnlctrl commented Nov 18, 2016

Sorry I forgot this... I agree with @posva that we should use a single resolve method, both internally and as public api. Let's wait for Evan's input on this.

@hogart
Copy link
Contributor Author

hogart commented Nov 18, 2016

@LinusBorg I'd like to, but I didn't found place for testing Router class.

@fnlctrl, @posva how do you imagine it? We need several pieces of info in link component, most of which are useless outside of that context. On the other hand, resolving algorithm stays the same, so it's either this or duplicating code.

@posva
Copy link
Member

posva commented Nov 18, 2016

@hogart By one method I meant that I'd rather have _getResolutionData inside resolve and use resolve everywhere

@hogart
Copy link
Contributor Author

hogart commented Nov 18, 2016

@posva I understand what you want, but, sorry, I don't see how we can use resolve in link component, because it requires additional data.
Can you please elaborate how in your vision it should work?

@posva
Copy link
Member

posva commented Nov 18, 2016

@hogart Oh, I wanted to say that resolve would return the whole object not just an href 😆

@hogart
Copy link
Contributor Author

hogart commented Nov 18, 2016

@posva that's definitely possible:) But in my opinion this pollutes API surface, are you guys sure about that?

@posva
Copy link
Member

posva commented Nov 18, 2016

no, I personally think it's ok. Why does it pollutes the api surface, is it because you may never use the rest of the returned object?

@hogart
Copy link
Contributor Author

hogart commented Nov 18, 2016

@posva yes, because of that.
Ok, I implement appropriate changes. Anything to land this PR already:)

@hogart
Copy link
Contributor Author

hogart commented Nov 20, 2016

I'm closing this PR because messed-up changelog, see #918 instead.

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

Successfully merging this pull request may close these issues.

8 participants