Skip to content

Support target="_blank" for <router-link> #830

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

Merged
merged 6 commits into from
Nov 13, 2016
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/components/link.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ export default {
// don't redirect on right click
/* istanbul ignore if */
if (e.button !== 0) return
// don't redirect if `target="_blank"`
/* istanbul ignore if */
const target = this.$el && this.$el.attributes.getNamedItem('target')
if (target && target.value === '_blank') return
Copy link
Member

Choose a reason for hiding this comment

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

Two things:

  • Why not const target = this.$el && this.$el.getAttribute('target')?
  • Won't this fail for target="_blank " (with an extra space)?

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed, I guess I'm just too unfamiliar with native dom api 😂


e.preventDefault()
if (this.replace) {
router.replace(to)
Expand Down