Skip to content

Commit

Permalink
Filter out false menu items (#69)
Browse files Browse the repository at this point in the history
  • Loading branch information
medusalix authored and sindresorhus committed May 29, 2019
1 parent 6b0467a commit 2529d65
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion fixture.js
Expand Up @@ -36,7 +36,8 @@ contextMenu({
],
append: () => {},
showCopyImageAddress: true,
showSaveImageAs: true
showSaveImageAs: true,
showInspectElement: false
});

(async () => {
Expand Down
2 changes: 1 addition & 1 deletion index.js
Expand Up @@ -19,7 +19,7 @@ const removeUnusedMenuItems = menuTemplate => {
let notDeletedPreviousElement;

return menuTemplate
.filter(menuItem => menuItem !== undefined && menuItem.visible !== false)
.filter(menuItem => menuItem !== undefined && menuItem !== false && menuItem.visible !== false)
.filter((menuItem, index, array) => {
const toDelete = menuItem.type === 'separator' && (!notDeletedPreviousElement || index === array.length - 1 || array[index + 1].type === 'separator');
notDeletedPreviousElement = toDelete ? notDeletedPreviousElement : menuItem;
Expand Down

0 comments on commit 2529d65

Please sign in to comment.