1
0
mirror of https://git.tuxpa.in/a/code-server.git synced 2024-12-29 05:35:25 +00:00
code-server-2/packages/vscode/src/fill/dom.ts
2019-02-05 11:16:06 -06:00

32 lines
1005 B
TypeScript

import * as dom from "vs/base/browser/dom";
import { IDisposable } from "vs/base/common/lifecycle";
// Firefox has no implementation of toElement.
if (!("toElement" in MouseEvent.prototype)) {
Object.defineProperty(MouseEvent.prototype, "toElement", {
get: function (): EventTarget | null {
// @ts-ignore
const event = this as MouseEvent;
switch (event.type) {
case "mouseup":
case "focusin":
case "mousenter":
case "mouseover":
case "dragenter":
return event.target;
default:
return event.relatedTarget;
}
},
});
}
const _addDisposableListener = dom.addDisposableListener;
// tslint:disable-next-line no-any
const addDisposableListener = (node: Element | Window | Document, type: string, handler: (event: any) => void, useCapture?: boolean): IDisposable => {
return _addDisposableListener(node, type === "mousewheel" ? "wheel" : type, handler, useCapture);
};
const target = dom as typeof dom;
target.addDisposableListener = addDisposableListener;