Skip to content

Commit

Permalink
Merge pull request #2153 from megawac/global
Browse files Browse the repository at this point in the history
Detect global in strict mode and WebWorkers
  • Loading branch information
jridgewell committed May 14, 2015
2 parents 01dda7e + 68bb747 commit fd11c93
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions underscore.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@
// 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);

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

0 comments on commit fd11c93

Please sign in to comment.