Skip to content

Commit

Permalink
Detect global in strict mode and WebWorkers; fixes #2152
Browse files Browse the repository at this point in the history
  • Loading branch information
megawac committed May 14, 2015
1 parent 4f2474c commit 2c0c2dd
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions underscore.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@
// Baseline setup
// --------------

// Establish the root object, `window` in the browser, or `exports` on the server.
var root = this;
// Establish the root object, `window` (`self`) in the browser, or `global` on the server.
// We use `self` instead of `window` for `WebWorker` support.
var root = (typeof self == 'object' && self.self == self && self) ||
(typeof global == 'object' && global.global == global && global);var root = (typeof self == 'object' && self.self == self && self) ||
(typeof global == 'object' && global.global == global && global);

// Save the previous value of the `_` variable.
var previousUnderscore = root._;
Expand Down Expand Up @@ -1562,4 +1565,4 @@
return _;
});
}
}.call(this));
}());

0 comments on commit 2c0c2dd

Please sign in to comment.