fix: use e.currentTarget instead of this in download link click handler

Cast to HTMLAnchorElement for precise typing of .id and .href.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
E Nelson
2026-04-24 11:17:07 -04:00
parent 48382c43b4
commit 9366f5d72b
5 changed files with 14 additions and 11 deletions

View File

@@ -3031,13 +3031,14 @@
"click.shinyDownloadLink auxclick.shinyDownloadLink",
"a.shiny-download-link",
function(e4) {
if (this.classList.contains("disabled")) {
const el = e4.currentTarget;
if (el.classList.contains("disabled")) {
e4.preventDefault();
return;
}
const evt = import_jquery25.default.Event("shiny:filedownload");
evt.name = this.id;
evt.href = this.href;
evt.name = el.id;
evt.href = el.href;
(0, import_jquery25.default)(document).trigger(evt);
}
);

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -38,16 +38,18 @@ $(document).on(
"click.shinyDownloadLink auxclick.shinyDownloadLink",
"a.shiny-download-link",
function (e: Event) {
const el = e.currentTarget as HTMLAnchorElement;
// Prevent clicks when the button is disabled.
if ((this as HTMLElement).classList.contains("disabled")) {
if (el.classList.contains("disabled")) {
e.preventDefault();
return;
}
const evt: FileDownloadEvent = $.Event("shiny:filedownload");
evt.name = this.id;
evt.href = this.href;
evt.name = el.id;
evt.href = el.href;
$(document).trigger(evt);
},
);