-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use Function("return this") to get global? #2152
Comments
Would be better to just create a root object on L12. var root = this || {}; |
Underscore doesn't use strict mode. |
It's not an issue of Underscore using strict mode, but the new ES6 module loaders forcing strict mode. |
Seriously? Strict mode is enforced now in "real" ES6? Or is this just "polyfill" module loaders being zealous? |
http://people.mozilla.org/~jorendorff/es6-draft.html#sec-strict-mode-code Ugh. Is this going to play nice with |
It's not strict mode exactly. The ES6 spec says that |
I stand corrected, it's always strict mode. |
Can we replace |
^ That would also add support for loading underscore in webworkers |
@jashkenas jest doesn't play well with loading underscore either. |
Also, this issue affects Backbone as well. Relevant issue: jashkenas/backbone#3566 |
@megawac |
See pull
|
ran into this when using babel-jest as scriptPreprocessor. Any idea? 1.8.3
|
Underscore currently breaks in
'strict'
mode while trying to access properties on the global object. The global object is being set using the(function(root) { ... })(this)
pattern. However, in this case,root
remainsundefined
and hence the issue.Using the
Function("return this")()
pattern instead alleviates the issue, though arguably ugly. Thoughts?Steps to reproduce: Import underscore in a
babel-jest
test harness. (uses strict mode)The text was updated successfully, but these errors were encountered: