提交 479bec0f 编写于 作者: M Matt Bierner

Strict null check contextMenuHandler

上级 e3fd4f0f
......@@ -493,6 +493,8 @@
"./vs/platform/configuration/test/node/configurationService.test.ts",
"./vs/platform/contextkey/browser/contextKeyService.ts",
"./vs/platform/contextkey/common/contextkey.ts",
"./vs/platform/contextview/browser/contextMenuHandler.ts",
"./vs/platform/contextview/browser/contextMenuService.ts",
"./vs/platform/contextview/browser/contextView.ts",
"./vs/platform/contextview/browser/contextViewService.ts",
"./vs/platform/credentials/test/node/keytar.test.ts",
......
......@@ -26,7 +26,7 @@ export interface IMenuOptions {
context?: any;
actionItemProvider?: IActionItemProvider;
actionRunner?: IActionRunner;
getKeyBinding?: (action: IAction) => ResolvedKeybinding;
getKeyBinding?: (action: IAction) => ResolvedKeybinding | null;
ariaLabel?: string;
enableMnemonics?: boolean;
anchorAlignment?: AnchorAlignment;
......
......@@ -21,9 +21,9 @@ import { attachMenuStyler } from 'vs/platform/theme/common/styler';
import { domEvent } from 'vs/base/browser/event';
export class ContextMenuHandler {
private element: HTMLElement;
private element: HTMLElement | null;
private elementDisposable: IDisposable;
private menuContainerElement: HTMLElement;
private menuContainerElement: HTMLElement | null;
private focusToReturn: HTMLElement;
constructor(
......@@ -37,7 +37,7 @@ export class ContextMenuHandler {
this.setContainer(element);
}
setContainer(container: HTMLElement): void {
setContainer(container: HTMLElement | null): void {
if (this.element) {
this.elementDisposable = dispose(this.elementDisposable);
this.element = null;
......@@ -96,12 +96,14 @@ export class ContextMenuHandler {
},
focus: () => {
menu.focus(!!delegate.autoSelectFirstItem);
if (menu) {
menu.focus(!!delegate.autoSelectFirstItem);
}
},
onHide: (didCancel?: boolean) => {
if (delegate.onHide) {
delegate.onHide(didCancel);
delegate.onHide(!!didCancel);
}
this.menuContainerElement = null;
......@@ -140,7 +142,7 @@ export class ContextMenuHandler {
}
let event = new StandardMouseEvent(e);
let element = event.target;
let element: HTMLElement | null = event.target;
while (element) {
if (element === this.menuContainerElement) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册