Skip to content

Commit

Permalink
Fix links with href="#" being pushed to Vue router
Browse files Browse the repository at this point in the history
Fixes #1011

Signed-off-by: nscuro <[email protected]>
  • Loading branch information
nscuro committed Sep 24, 2024
1 parent 9ff0859 commit 59e4e85
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,14 @@ export default {
const linkTarget = target.getAttribute('target');
if (/\b_blank\b/i.test(linkTarget)) return;
}
// don't handle if `href="#"`
if (target && target.getAttribute) {
const linkHref = target.getAttribute('href');
if ('#' === linkHref) {
event.preventDefault();
return;
}
}
// don't handle same page links/anchors
const url = new URL(target.href);
const to = url.pathname;
Expand Down

0 comments on commit 59e4e85

Please sign in to comment.