Skip to content

Commit 225f8fb

Browse files
committed
refactor(client/router): drop redundant download attribute filter
`event.downloadRequest != null` already catches links with a `download` attribute (including `download=""`), so the `sourceElement.hasAttribute('download')` check was dead. Keep the `target` check — `target="_self"` and named targets still fire the navigate event in the current window and should not be intercepted.
1 parent b1d3b0d commit 225f8fb

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

src/client/app/router/navigationApi.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,14 +93,15 @@ export const createNavigationApiRouterStrategy: RouterStrategyFactory = (
9393
const src = event.sourceElement
9494
// Mirror the legacy click-handler filters when the navigation was
9595
// element-initiated (e.g. link click). Programmatic navigations have a
96-
// null sourceElement and are always considered eligible.
96+
// null sourceElement and are always considered eligible. `download` is
97+
// handled by `event.downloadRequest` above.
9798
if (src) {
9899
if (src.closest('.vp-raw')) return
99100
// covers docsearch action buttons and button-wrapped link content
100101
if (src.closest('button') || src.querySelector('button')) return
101102
if (
102103
(src instanceof HTMLAnchorElement || src instanceof SVGAElement) &&
103-
(src.hasAttribute('download') || src.hasAttribute('target'))
104+
src.hasAttribute('target')
104105
) {
105106
return
106107
}

0 commit comments

Comments
 (0)