2019-02-01 18:38:42 +00:00
|
|
|
import * as dom from "vs/base/browser/dom";
|
|
|
|
import { IDisposable } from "vs/base/common/lifecycle";
|
|
|
|
|
2019-01-19 00:04:24 +00:00
|
|
|
// Firefox has no implementation of toElement.
|
2019-01-08 00:46:19 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
});
|
|
|
|
}
|
2019-02-01 18:38:42 +00:00
|
|
|
|
|
|
|
const _addDisposableListener = dom.addDisposableListener;
|
2019-02-02 01:55:32 +00:00
|
|
|
// tslint:disable-next-line no-any
|
2019-02-01 18:38:42 +00:00
|
|
|
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;
|