Skip to content

Commit

Permalink
Skip custom click behavior on links when the download attribute is set
Browse files Browse the repository at this point in the history
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 jupyterlab#5443
  • Loading branch information
jasongrout committed Oct 10, 2019
1 parent 1293dd2 commit 2d23e79
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions packages/rendermime-extension/src/index.ts
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion packages/rendermime-interfaces/src/index.ts
Expand Up @@ -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.
*
Expand Down

0 comments on commit 2d23e79

Please sign in to comment.