Browse Source

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.
tags/v4.26.1
HE Shi-Jun 9 months ago
parent
commit
48f06041d1
No account linked to committer's email address
1 changed files with 1 additions and 1 deletions
  1. 1
    1
      buildin/global.js

+ 1
- 1
buildin/global.js View File

@@ -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;

Loading…
Cancel
Save