Skip to content
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

2.0 doesn't respect target="_blank" attr #827

Closed
hogart opened this issue Oct 24, 2016 · 12 comments
Closed

2.0 doesn't respect target="_blank" attr #827

hogart opened this issue Oct 24, 2016 · 12 comments

Comments

@hogart
Copy link
Contributor

hogart commented Oct 24, 2016

Following code doesn't open new tab/window:

router-link("v-bind:to"="{name: 'play', params: {ifid: ifid}}", target="_blank") Play (new tab)

I'm upgrading my app from 1.x where appropriate equivalent of this code worked. Here's repro pen: http://codepen.io/hogart/pen/ZpPGXY?editors=1010

@fnlctrl
Copy link
Member

fnlctrl commented Oct 24, 2016

It's no longer supported, please use <a> tags instead.

@fnlctrl fnlctrl closed this as completed Oct 24, 2016
@hogart
Copy link
Contributor Author

hogart commented Oct 24, 2016

Manually creating links is error prone and can't be really considered solution — аlas, router instance doesn't provide method for reverse url resolving.

I understand that this is quite rare use case, but this is obvious regression and as such should be at least mentioned in upgrade guide.

@fnlctrl
Copy link
Member

fnlctrl commented Oct 24, 2016

аlas, router instance doesn't provide method for reverse url resolving.

It has.. though it's not documented (since it's very unlikely that someone needs it):
router.match(), you can put whatever in router-link's to prop to it, e.g. router.match({name:'foo'})
and to get the url, use router.match({name:'foo'}).fullPath

I understand that this is quite rare use case, but this is obvious regression and as such should be at least mentioned in upgrade guide.

Sorry about that, just created a PR to fix this: https://github.com/vuejs/vuejs.org/pull/539/files

@hogart
Copy link
Contributor Author

hogart commented Oct 24, 2016

Yeah, I already dug out this method, although it's not full equivalent of what's happening in router-link render function. Can I rely upon it in a sense it get's documented some time and won't disappear?

@fnlctrl
Copy link
Member

fnlctrl commented Oct 25, 2016

although it's not full equivalent of what's happening in router-link render function.

Yeah, it doesn't handle base.. https://github.com/vuejs/vue-router/blob/dev/src/components/link.js#L30-L33

Can I rely upon it in a sense it get's documented some time and won't disappear?

It's unlikely to be documented, and I can't guarantee its consistence... Please use at your own risk.

@posva
Copy link
Member

posva commented Oct 25, 2016

@fnlctrl Couldn't we implement this with window.open and provide a target prop?

@fnlctrl
Copy link
Member

fnlctrl commented Oct 25, 2016

@posva Evan fixed this for 0.7 (c955be3), but I don't know if he intentionally removed this in 2.0. It would be easy to support though.

@posva
Copy link
Member

posva commented Oct 25, 2016

@fnlctrl I think we should 😄
Let's talk about this on slack

@hogart
Copy link
Contributor Author

hogart commented Oct 25, 2016

@fnlctrl while target="_blank" is indeed corner case, reverse url resolve can be useful in other cases. Imagine we're building isomorphic app and we need to email user some link. Or we doing something like google drive or bit.ly and we need to provide links in text form to copy them.

@fnlctrl fnlctrl reopened this Oct 25, 2016
@fnlctrl
Copy link
Member

fnlctrl commented Oct 25, 2016

Well for the "target=_blank" issue I've created a PR: #830
@hogart As for the reverse url resolve, would you mind opening a new issue for discussion?

@LinusBorg
Copy link
Member

LinusBorg commented Oct 25, 2016

Srsly? Well, this lib gone south really fast:(

Sidenote: Is that kind of behaviour necessary?

@yyx990803
Copy link
Member

fixed by merging #830

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

No branches or pull requests

5 participants