Skip to content

Commit

Permalink
chore: warn when using the deprecated new-window event (#34528)
Browse files Browse the repository at this point in the history
  • Loading branch information
miniak committed Jun 16, 2022
1 parent bad8d5e commit f418a49
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/browser/guest-window-manager.ts
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 @@ -155,6 +155,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 f418a49

Please sign in to comment.