From 59e4e852c8218e1e9bfeef766a6c0809d2fbccbd Mon Sep 17 00:00:00 2001 From: nscuro Date: Tue, 24 Sep 2024 20:14:24 +0200 Subject: [PATCH] Fix links with `href="#"` being pushed to Vue router Fixes #1011 Signed-off-by: nscuro --- src/App.vue | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/App.vue b/src/App.vue index 02ce9bec0..bdd38a598 100644 --- a/src/App.vue +++ b/src/App.vue @@ -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;