Skip to content
This repository has been archived by the owner on Oct 30, 2023. It is now read-only.

Commit

Permalink
chore: warn when using the deprecated new-window event (electron#34528)
Browse files Browse the repository at this point in the history
  • Loading branch information
miniak authored and khalwa committed Feb 22, 2023
1 parent 16df64e commit 3aa4178
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/browser/guest-window-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* out-of-process (cross-origin) are created here. "Embedder" roughly means
* "parent."
*/
import { BrowserWindow } from 'electron/main';
import { BrowserWindow, deprecate } from 'electron/main';
import type { BrowserWindowConstructorOptions, Referrer, WebContents, LoadURLOptions } from 'electron/main';
import { parseFeatures } from '@electron/internal/browser/parse-features-string';

Expand Down Expand Up @@ -161,6 +161,10 @@ function emitDeprecatedNewWindowEvent ({ event, embedder, guest, windowOpenArgs,
...parseContentTypeFormat(postData)
} : null;

if (embedder.listenerCount('new-window') > 0) {
deprecate.log('The new-window event is deprecated and will be removed. Please use contents.setWindowOpenHandler() instead.');
}

embedder.emit(
'new-window',
event,
Expand Down

0 comments on commit 3aa4178

Please sign in to comment.