fix: screen EventEmitter methods with remote (#26809)

* fix: screen EventEmitter methods with remote

* Review feedback
This commit is contained in:
Shelley Vohr 2020-12-07 20:47:48 -08:00 committed by GitHub
parent e87061398b
commit b788ceb7bd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,3 +1,5 @@
import { EventEmitter } from 'events';
const { createScreen } = process._linkedBinding('electron_common_screen');
let _screen: Electron.Screen;
@ -36,5 +38,11 @@ export default new Proxy({}, {
getOwnPropertyDescriptor: (target, property: string) => {
createScreenIfNeeded();
return Reflect.getOwnPropertyDescriptor(_screen, property);
},
getPrototypeOf: () => {
// This is necessary as a result of weirdness with EventEmitterMixin
// and FunctionTemplate - we need to explicitly ensure it's returned
// in the prototype.
return EventEmitter.prototype;
}
});