Skip to content

Commit

Permalink
Merge pull request #140 from nobkd/patch-2
Browse files Browse the repository at this point in the history
fix(page-router): don't prevent opening `_blank` target
  • Loading branch information
tipiirai authored Jan 3, 2024
2 parents d53b7d9 + d4363aa commit 19acf49
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/nuekit/src/browser/page-router.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,12 @@ export function onclick(root, fn) {
root.addEventListener('click', e => {
const el = e.target.closest('[href]')
const path = el?.getAttribute('href')
const target = el?.getAttribute('target')

// event ignore
if (e.defaultPrevented || e.metaKey || e.ctrlKey || e.shiftKey || e.altKey ||
!path || path[0] == '#' || path.includes('//') || path.startsWith('mailto:')) return
!path || path[0] == '#' || path.includes('//') || path.startsWith('mailto:') ||
target == '_blank') return

// all good
if (path != location.pathname) fn(path)
Expand Down

0 comments on commit 19acf49

Please sign in to comment.