Skip to content
Snippets Groups Projects
Commit b45a445c authored by Rene Saarsoo's avatar Rene Saarsoo
Browse files

Fix loading of esprima.js.

Let Esprima have its window object - otherwise it'll just crash.
parent f5f4e0a9
No related branches found
No related tags found
No related merge requests found
...@@ -14,7 +14,13 @@ module JsDuck ...@@ -14,7 +14,13 @@ module JsDuck
def initialize def initialize
@v8 = V8::Context.new @v8 = V8::Context.new
esprima = File.dirname(File.dirname(File.dirname(File.expand_path(__FILE__))))+"/esprima/esprima.js"; esprima = File.dirname(File.dirname(File.dirname(File.expand_path(__FILE__))))+"/esprima/esprima.js";
# Esprima attempts to assign to window.esprima, but our v8
# engine has no global window variable defined. So define our
# own and then grab esprima out from it again.
@v8.eval("var window = {};")
@v8.load(esprima) @v8.load(esprima)
@v8.eval("var esprima = window.esprima;")
end end
# Parses JavaScript source code using Esprima.js # Parses JavaScript source code using Esprima.js
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment