From 7487f87e8a08bd8df13dcc0a4fa6f2fdecfe47cc Mon Sep 17 00:00:00 2001 From: Andriy Lysnevych Date: Tue, 25 Apr 2023 23:59:57 +0300 Subject: [PATCH] Remove broken check (#1157) * Remove broken check The check, for some reason, was not removed in this PR: https://github.com/pubkey/broadcast-channel/pull/1037 * Force `type: 'node'` for Node.js v18 in some tests * Fix Node.js v18 fallback to `node` method * Refactor if statement --- src/methods/native.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/methods/native.js b/src/methods/native.js index e337bbb9..d06862b7 100644 --- a/src/methods/native.js +++ b/src/methods/native.js @@ -42,10 +42,10 @@ export function onMessage(channelState, fn) { } export function canBeUsed() { - if (typeof window === 'undefined') { - return false; - } - if (typeof BroadcastChannel === 'function') { + if ( + (typeof window !== 'undefined' || typeof self !== 'undefined') && + typeof BroadcastChannel === 'function' + ) { if (BroadcastChannel._pubkey) { throw new Error( 'BroadcastChannel: Do not overwrite window.BroadcastChannel with this module, this is not a polyfill'