Skip to content

Commit 48f0604

Browse files
authored
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.
1 parent a230148 commit 48f0604

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

buildin/global.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ g = (function() {
77

88
try {
99
// This works if eval is allowed (see CSP)
10-
g = g || Function("return this")() || (1, eval)("this");
10+
g = g || new Function("return this")();
1111
} catch (e) {
1212
// This works if the window reference is available
1313
if (typeof window === "object") g = window;

0 commit comments

Comments
 (0)