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
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -14,7 +14,13 @@ module JsDuck
    def initialize
      @v8 = V8::Context.new
      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.eval("var esprima = window.esprima;")
    end

    # Parses JavaScript source code using Esprima.js