Skip to content

Commit

Permalink
chore: warn when using the deprecated new-window event (#34593)
Browse files Browse the repository at this point in the history
Co-authored-by: Milan Burda <milan.burda@gmail.com>
  • Loading branch information
trop[bot] and miniak committed Jun 20, 2022
1 parent 82a6e9b commit 10062c9
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 10062c9

Please sign in to comment.