Browse Source

fix: screen EventEmitter methods with remote (#26809)

* fix: screen EventEmitter methods with remote

* Review feedback
Shelley Vohr 4 years ago
parent
commit
b788ceb7bd
1 changed files with 8 additions and 0 deletions
  1. 8 0
      lib/browser/api/screen.ts

+ 8 - 0
lib/browser/api/screen.ts

@@ -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;
   }
 });