Skip to content

Commit 10e534d

Browse files
committed
fix v-link with target="_blank" (fix #340)
1 parent 9642bbf commit 10e534d

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/directives/link.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,6 @@ export default function (Vue) {
3434
this.router = vm.$route.router
3535
// update things when the route changes
3636
this.unwatch = vm.$watch('$route', bind(this.onRouteUpdate, this))
37-
// no need to handle click if link expects to be opened
38-
// in a new window/tab.
39-
/* istanbul ignore if */
40-
if (this.el.tagName === 'A' &&
41-
this.el.getAttribute('target') === '_blank') {
42-
return
43-
}
44-
// handle click
45-
this.el.addEventListener('click', bind(this.onClick, this))
4637
// check if active classes should be applied to a different element
4738
this.activeEl = this.el
4839
var parent = this.el.parentNode
@@ -53,6 +44,15 @@ export default function (Vue) {
5344
}
5445
parent = parent.parentNode
5546
}
47+
// no need to handle click if link expects to be opened
48+
// in a new window/tab.
49+
/* istanbul ignore if */
50+
if (this.el.tagName === 'A' &&
51+
this.el.getAttribute('target') === '_blank') {
52+
return
53+
}
54+
// handle click
55+
this.el.addEventListener('click', bind(this.onClick, this))
5656
},
5757

5858
update (target) {

0 commit comments

Comments
 (0)