Skip to content

Commit 84feb91

Browse files
authored
Merge pull request #24 from daankauwenberg/master
Check for anchors as parents instead of only the event.target in the router
2 parents b4412c8 + 35b9f0b commit 84feb91

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/theme/scripts/router.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,11 @@ class Router {
3434
}
3535

3636
async _onLinkClick(event) {
37-
if(event.target.tagName !== 'A') return;
38-
const link = new URL(event.target.href);
37+
// See if what is clicked has an anchor as parent or is a link itself. If so create URL otherwise return.
38+
const linkElement = event.target.closest('a');
39+
if (!linkElement) return;
40+
const link = new URL(linkElement.href);
41+
3942
// If it’s an external link, just navigate.
4043
if(link.host !== this._hostname) {
4144
return;

0 commit comments

Comments
 (0)