Drop unuseful `eval` call

If use CSP (without `unsafe-eval`), both `new Function` and `eval` will be forbidden, so `eval` part is just dead code.

The only possibility `eval` part would run was `new Function('return this')()` return a falsy value, but it never possible as the spec (Is there any old engine violate this? Never heard about that.)

This pr also add `new` keyword to make the code a little bit explicit.
This commit is contained in:
HE Shi-Jun 2018-11-16 17:20:53 +08:00 提交者 GitHub
父節點 a2301484a5
當前提交 48f06041d1
沒有發現已知的金鑰在資料庫的簽署中
GPG 金鑰 ID: 4AEE18F83AFDEB23
共有 1 個檔案被更改,包括 1 行新增1 行删除

查看文件

@ -7,7 +7,7 @@ g = (function() {
try {
// This works if eval is allowed (see CSP)
g = g || Function("return this")() || (1, eval)("this");
g = g || new Function("return this")();
} catch (e) {
// This works if the window reference is available
if (typeof window === "object") g = window;