浏览代码

[JS] use `Function(...)` instead of indirect eval to check for present of `console`.
See https://github.com/HaxeFoundation/haxe/commit/6ded3f624bfb7c57dd8ab3af9a05049ffaae9d43#commitcomment-9317762

Andy Li 10 年之前
父节点
当前提交
75e4d1c72d
共有 1 个文件被更改,包括 1 次插入1 次删除
  1. 1 1
      genjs.ml

+ 1 - 1
genjs.ml

@@ -1291,7 +1291,7 @@ let generate com =
 
 	(* Provide console for environments that may not have it. *)
 	if not (Common.defined com Define.JsEs5) then
-		spr ctx "var console = (1,eval)('this').console || {log:function(){}};\n";
+		spr ctx "var console = Function(\"return typeof console != 'undefined' ? console : {log:function(){}}\")();\n";
 
 	(* TODO: fix $estr *)
 	let vars = [] in