2019-01-19 07:04:24 +07:00
|
|
|
// Firefox has no implementation of toElement.
|
2019-01-08 07:46:19 +07: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;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
});
|
|
|
|
}
|