From 2d23e7985de7370f7ced78091afec210ae12937f Mon Sep 17 00:00:00 2001 From: Jason Grout Date: Thu, 10 Oct 2019 09:35:07 -0700 Subject: [PATCH] Skip custom click behavior on links when the download attribute is set The presumption here is that if an A node has a download attribute explicitly set, the user really does want to download the file rather than opening the file in JLab. Fixes #5443 --- packages/rendermime-extension/src/index.ts | 5 +++++ packages/rendermime-interfaces/src/index.ts | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/rendermime-extension/src/index.ts b/packages/rendermime-extension/src/index.ts index 3796135852c9..da0ef53ad9f5 100644 --- a/packages/rendermime-extension/src/index.ts +++ b/packages/rendermime-extension/src/index.ts @@ -80,6 +80,11 @@ function activate( ? null : { handleLink: (node: HTMLElement, path: string, id?: string) => { + // If node has the download attribute explicitly set, use the + // default browser downloading behavior. + if (node.tagName === 'A' && node.hasAttribute('download')) { + return; + } app.commandLinker.connectNode(node, CommandIDs.handleLink, { path, id diff --git a/packages/rendermime-interfaces/src/index.ts b/packages/rendermime-interfaces/src/index.ts index a9844ebbefdf..43dd2f094115 100644 --- a/packages/rendermime-interfaces/src/index.ts +++ b/packages/rendermime-interfaces/src/index.ts @@ -320,7 +320,7 @@ export namespace IRenderMime { /** * Add the link handler to the node. * - * @param node: the node for which to handle the link. + * @param node: the anchor node for which to handle the link. * * @param path: the path to open when the link is clicked. *