Skip to content

Commit

Permalink
Fixes context menu hit test to deal with svg nodes.
Browse files Browse the repository at this point in the history
  • Loading branch information
jasongrout committed Sep 19, 2019
1 parent 35b4789 commit 63ad63f
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions packages/application/src/frontend.ts
Expand Up @@ -105,8 +105,8 @@ export abstract class JupyterFrontEnd<

/**
* Walks up the DOM hierarchy of the target of the active `contextmenu`
* event, testing the nodes for a user-supplied funcion. This can
* be used to find a node on which to operate, given a context menu click.
* event, testing each HTMLElement ancestor for a user-supplied funcion. This can
* be used to find an HTMLElement on which to operate, given a context menu click.
*
* @param test - a function that takes an `HTMLElement` and returns a
* boolean for whether it is the element the requester is seeking.
Expand All @@ -118,16 +118,16 @@ export abstract class JupyterFrontEnd<
): HTMLElement | undefined {
if (
!this._contextMenuEvent ||
!(this._contextMenuEvent.target instanceof HTMLElement)
!(this._contextMenuEvent.target instanceof Node)
) {
return undefined;
}
let node = this._contextMenuEvent.target as HTMLElement;
let node = this._contextMenuEvent.target;
do {
if (test(node)) {
if (node instanceof HTMLElement && test(node)) {
return node;
}
node = node.parentNode as HTMLElement;
node = node.parentNode;
} while (node && node.parentNode && node !== node.parentNode);
return undefined;

Expand Down

0 comments on commit 63ad63f

Please sign in to comment.