From 923d1020fcfd59a08aa311b5b6b91390613814e5 Mon Sep 17 00:00:00 2001 From: Jon Eisen Date: Tue, 2 Jun 2015 10:32:44 -0600 Subject: [PATCH 1/2] Check window first in setting global object --- index.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index 657a261..81439d8 100644 --- a/index.js +++ b/index.js @@ -11,9 +11,10 @@ var defaultVars = { return 'require(' + JSON.stringify(processPath) + ')'; }, global: function () { - return 'typeof global !== "undefined" ? global : ' - + 'typeof self !== "undefined" ? self : ' - + 'typeof window !== "undefined" ? window : {}' + // Check window first because `window.global` can exist in browsers. + return 'typeof window !== "undefined" ? window : ' + + 'typeof global !== "undefined" ? global : ' + + 'typeof self !== "undefined" ? self : {}' ; }, Buffer: function () { From 4cd3668f3d74f25b8a8e1e78f7441c0e9b0ee308 Mon Sep 17 00:00:00 2001 From: Jon Eisen Date: Tue, 2 Jun 2015 13:37:26 -0600 Subject: [PATCH 2/2] Check to make sure window matches what a window should have on it. --- index.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/index.js b/index.js index 81439d8..e786939 100644 --- a/index.js +++ b/index.js @@ -11,8 +11,7 @@ var defaultVars = { return 'require(' + JSON.stringify(processPath) + ')'; }, global: function () { - // Check window first because `window.global` can exist in browsers. - return 'typeof window !== "undefined" ? window : ' + return 'typeof window !== "undefined" && window.document && window.document.implementation ? window : ' + 'typeof global !== "undefined" ? global : ' + 'typeof self !== "undefined" ? self : {}' ;