Skip to content
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? #3566

Closed
creatorrr opened this issue Apr 14, 2015 · 1 comment
Closed

Use Function("return this") to get global? #3566

creatorrr opened this issue Apr 14, 2015 · 1 comment

Comments

@creatorrr
Copy link

Backbone 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 remains undefined and hence the issue.

Using the Function("return this")() pattern instead alleviates the issue, though arguably ugly. Thoughts?

Steps to reproduce: Import backbone in a babel-jest test harness. (uses strict mode)

@creatorrr
Copy link
Author

This issue affects Underscore as well. Relevant issue: jashkenas/underscore#2152

megawac added a commit to megawac/backbone that referenced this issue May 13, 2015
jashkenas added a commit that referenced this issue May 13, 2015
Amend #3566 fix; global detection
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants