code-server/packages/vscode/src/fill/dom.ts
2019-02-05 11:15:51 -06:00

20 lines
468 B
TypeScript

// 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;
}
},
});
}