Better onRootClick implementation

Thanks John
pull/6454/head
Chocobozzz 2024-06-21 09:51:07 +02:00
parent ab22399da0
commit d5323a641b
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
1 changed files with 3 additions and 4 deletions

View File

@ -34,16 +34,15 @@ export class PluginPagesComponent implements OnDestroy, AfterViewInit {
onRootClick (event: Event) {
const target = event.target as HTMLElement
if (!target) return
if (target.tagName !== 'A') return
const a = target as HTMLAnchorElement
const a = target.closest('a')
if (!a) return
// Get the href attribute set by the dev, not the one calculated by JS to detect if it's a relative/external link
const href = a.getAttribute('href')
if (a.target !== '_blank' && href.startsWith('/')) {
if (!a.target && href.startsWith('/')) {
event.preventDefault()
event.stopPropagation()