diff --git a/src/cytoscape-context-menus.js b/src/cytoscape-context-menus.js index 353b8fa..73fef0e 100644 --- a/src/cytoscape-context-menus.js +++ b/src/cytoscape-context-menus.js @@ -38,11 +38,12 @@ export function contextMenus(opts) { // Check for each menuItem, if show is true, show the menuItem for (let menuItem of cxtMenu.children) { if (menuItem instanceof MenuItem) { + const is = typeof target.is === 'function' ? (selector) => target.is(selector) : () => false; let shouldDisplay = (target === cy) ? // If user clicked in cy area then show core items menuItem.coreAsWell : // If selector of the item matches then show - target.is(menuItem.selector); + is(menuItem.selector); // User clicked on empty area and menuItem is core if (shouldDisplay && menuItem.show) { cxtMenu.display(); diff --git a/src/utils.js b/src/utils.js index c5293cc..86aa4ba 100644 --- a/src/utils.js +++ b/src/utils.js @@ -19,7 +19,7 @@ export function matches(el, selector) { export function isElementHidden(elem) { return elem.offsetWidth <= 0 && elem.offsetHeight <= 0 || - ((elem.style && elem.style.display) || getComputedStyle(elem)['display']); + ((elem.style && elem.style.display === 'none') || getComputedStyle(elem)['display'] === 'none'); } export function isElementVisible(elem) {