Skip to content

Commit

Permalink
Merge pull request #24 from daankauwenberg/master
Browse files Browse the repository at this point in the history
Check for anchors as parents instead of only the event.target in the router
  • Loading branch information
surma authored Oct 11, 2018
2 parents b4412c8 + 35b9f0b commit 84feb91
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/theme/scripts/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,11 @@ class Router {
}

async _onLinkClick(event) {
if(event.target.tagName !== 'A') return;
const link = new URL(event.target.href);
// See if what is clicked has an anchor as parent or is a link itself. If so create URL otherwise return.
const linkElement = event.target.closest('a');
if (!linkElement) return;
const link = new URL(linkElement.href);

// If it’s an external link, just navigate.
if(link.host !== this._hostname) {
return;
Expand Down

0 comments on commit 84feb91

Please sign in to comment.