Skip to content

Commit

Permalink
fix(browser): fix referencing global order
Browse files Browse the repository at this point in the history
Prioritize referencing Node.js' global to prevent reference error for some environment.

Fix #1778
  • Loading branch information
netil committed Dec 7, 2020
1 parent 109c87d commit 8f84cb3
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/module/browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ export {win as window, doc as document};
const win = (() => {
const def = o => typeof o !== "undefined" && o;

return def(self) || def(window) || def(global) || def(globalThis) || Function("return this")();
// Prioritize referencing Node.js global first to prevent refence error
// https://github.com/naver/billboard.js/issues/1778
return def(global) || def(globalThis) || def(self) || def(window) || Function("return this")();
})();
/* eslint-enable no-new-func, no-undef */

Expand Down

0 comments on commit 8f84cb3

Please sign in to comment.