paulmillr / es6-shim

ECMAScript 6 compatibility shims for legacy JS engines
http://paulmillr.com
MIT License
3.11k stars 389 forks source link

A more reliable method to get the global object #259

Closed ljharb closed 10 years ago

ljharb commented 10 years ago

Fixes #258.

This uses eval via the Function constructor, which is awful, but I can't come up with a better method in strict mode. I could also do (function () { return this; }()) in non-strict mode, but then I'd have to make the outer wrapper of the shim not be in strict mode.

ljharb commented 10 years ago

@david-risney, can you test this pr in a web worker, and confirm that it still works? @tavwizard, can you test this pr in node-webkit, and confirm that it now works?

david-risney commented 10 years ago

Yep, looks good. I ran the worker test I had added with my previous change and it continues to pass with your change.

tavwizard commented 10 years ago

work fine under node-webkit