mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-12 03:47:50 +00:00
Replace window var with root to better grab the global when using custom IIFEs.
Former-commit-id: f79834c6b53d692e85801d6258cd8beb35c776c2
This commit is contained in:
19
dist/lodash.compat.js
vendored
19
dist/lodash.compat.js
vendored
@@ -7,7 +7,7 @@
|
||||
* Copyright 2009-2013 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
|
||||
* Available under MIT license <http://lodash.com/license>
|
||||
*/
|
||||
;(function(window) {
|
||||
;(function() {
|
||||
|
||||
/** Used as a safe reference for `undefined` in pre ES5 environments */
|
||||
var undefined;
|
||||
@@ -126,16 +126,19 @@
|
||||
'\u2029': 'u2029'
|
||||
};
|
||||
|
||||
/** Used as a reference to the global object */
|
||||
var root = (objectTypes[typeof window] && window) || this;
|
||||
|
||||
/** Detect free variable `exports` */
|
||||
var freeExports = objectTypes[typeof exports] && exports;
|
||||
|
||||
/** Detect free variable `module` */
|
||||
var freeModule = objectTypes[typeof module] && module && module.exports == freeExports && module;
|
||||
|
||||
/** Detect free variable `global` from Node.js or Browserified code and use it as `window` */
|
||||
/** Detect free variable `global` from Node.js or Browserified code and use it as `root` */
|
||||
var freeGlobal = objectTypes[typeof global] && global;
|
||||
if (freeGlobal && (freeGlobal.global === freeGlobal || freeGlobal.window === freeGlobal)) {
|
||||
window = freeGlobal;
|
||||
root = freeGlobal;
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
@@ -437,7 +440,7 @@
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @category Utilities
|
||||
* @param {Object} [context=window] The context object.
|
||||
* @param {Object} [context=root] The context object.
|
||||
* @returns {Function} Returns the `lodash` function.
|
||||
*/
|
||||
function runInContext(context) {
|
||||
@@ -445,7 +448,7 @@
|
||||
// after built-in constructors like `Object`, for the creation of literals.
|
||||
// ES5 clears this up by stating that literals must use built-in constructors.
|
||||
// See http://es5.github.io/#x11.1.5.
|
||||
context = context ? _.defaults(window.Object(), context, _.pick(window, contextProps)) : window;
|
||||
context = context ? _.defaults(root.Object(), context, _.pick(root, contextProps)) : root;
|
||||
|
||||
/** Native constructor references */
|
||||
var Array = context.Array,
|
||||
@@ -6516,7 +6519,7 @@
|
||||
// case Lo-Dash was injected by a third-party script and not intended to be
|
||||
// loaded as a module. The global assignment can be reverted in the Lo-Dash
|
||||
// module via its `noConflict()` method.
|
||||
window._ = _;
|
||||
root._ = _;
|
||||
|
||||
// define as an anonymous module so, through path mapping, it can be
|
||||
// referenced as the "underscore" module
|
||||
@@ -6537,6 +6540,6 @@
|
||||
}
|
||||
else {
|
||||
// in a browser or Rhino
|
||||
window._ = _;
|
||||
root._ = _;
|
||||
}
|
||||
}(this));
|
||||
}.call(this));
|
||||
|
||||
Reference in New Issue
Block a user