Skip to content

Commit 6f5ce40

Browse files
RezaHaidariyyx990803
authored andcommitted
fix target _blank when anchor has children (#1290)
* fix target _blank when anchor has children Couple of days ago, we have faced an issue with out non-SPA project: Once you add a child element to a ``<router-link>`` with ``target="_blank"`` attribute, it wouldn't fire on a new tab. check this fiddle: https://jsfiddle.net/asynchronous/dnLs1dm4/10/ I've changed ``gaurdEvent`` method in ``link`` component so it could fix this issue. * Update link.js * Update link.js
1 parent a1de424 commit 6f5ce40

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/components/link.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,8 @@ function guardEvent (e) {
9191
// don't redirect on right click
9292
if (e.button !== undefined && e.button !== 0) return
9393
// don't redirect if `target="_blank"`
94-
if (e.target && e.target.getAttribute) {
95-
const target = e.target.getAttribute('target')
94+
if (e.currentTarget && e.currentTarget.getAttribute) {
95+
const target = e.currentTarget.getAttribute('target')
9696
if (/\b_blank\b/i.test(target)) return
9797
}
9898
// this may be a Weex event which doesn't have this method

0 commit comments

Comments
 (0)