Skip to content

Commit a8c2039

Browse files
authored
Merge pull request #1012 from nscuro/issue-1011
Fix links with `href="#"` being pushed to Vue router
2 parents 9ff0859 + 59e4e85 commit a8c2039

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/App.vue

+8
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,14 @@ export default {
125125
const linkTarget = target.getAttribute('target');
126126
if (/\b_blank\b/i.test(linkTarget)) return;
127127
}
128+
// don't handle if `href="#"`
129+
if (target && target.getAttribute) {
130+
const linkHref = target.getAttribute('href');
131+
if ('#' === linkHref) {
132+
event.preventDefault();
133+
return;
134+
}
135+
}
128136
// don't handle same page links/anchors
129137
const url = new URL(target.href);
130138
const to = url.pathname;

0 commit comments

Comments
 (0)