mirror of
https://github.com/electron/electron.git
synced 2026-01-06 22:24:03 -05:00
feat: WebContents extends EventEmitter
This commit is contained in:
@@ -8,6 +8,7 @@ import { IPC_MESSAGES } from '@electron/internal/common/ipc-messages';
|
||||
import { app, session, webFrameMain, dialog } from 'electron/main';
|
||||
import type { BrowserWindowConstructorOptions, MessageBoxOptions, NavigationEntry } from 'electron/main';
|
||||
|
||||
import { EventEmitter } from 'events';
|
||||
import * as path from 'path';
|
||||
import * as url from 'url';
|
||||
|
||||
@@ -118,6 +119,8 @@ const binding = process._linkedBinding('electron_browser_web_contents');
|
||||
const printing = process._linkedBinding('electron_browser_printing');
|
||||
const { WebContents } = binding as { WebContents: { prototype: Electron.WebContents } };
|
||||
|
||||
Object.setPrototypeOf(WebContents.prototype, EventEmitter.prototype);
|
||||
|
||||
WebContents.prototype.postMessage = function (...args) {
|
||||
return this.mainFrame.postMessage(...args);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user