From e28e04a99030ef968a2ab1f9b3d9ed7ea01b7797 Mon Sep 17 00:00:00 2001 From: jdalton Date: Tue, 17 Mar 2015 20:01:00 -0700 Subject: [PATCH] Add `freeSelf` as a fallback for when `freeWindow` is unavailable. --- lodash.src.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lodash.src.js b/lodash.src.js index e8b4db648..a97783930 100644 --- a/lodash.src.js +++ b/lodash.src.js @@ -268,8 +268,11 @@ /** Detect free variable `global` from Node.js. */ var freeGlobal = freeExports && freeModule && typeof global == 'object' && global; + /** Detect free variable `self`. */ + var freeSelf = objectTypes[typeof self] && self && self.Object && self; + /** Detect free variable `window`. */ - var freeWindow = objectTypes[typeof window] && window; + var freeWindow = objectTypes[typeof window] && window && window.Object && window; /** Detect the popular CommonJS extension `module.exports`. */ var moduleExports = freeModule && freeModule.exports === freeExports && freeExports; @@ -280,7 +283,7 @@ * The `this` value is used if it is the global object to avoid Greasemonkey's * restricted `window` object, otherwise the `window` object is used. */ - var root = freeGlobal || ((freeWindow !== (this && this.window)) && freeWindow) || this; + var root = freeGlobal || ((freeWindow !== (this && this.window)) && freeWindow) || freeSelf || this; /*--------------------------------------------------------------------------*/