Over the past few days I’ve been attempting to glue Jurassic to a DOM tree. While there's still a massive amount of work to do, I’m attempting to solve some of the basics first. I hit a small snag with 'Window' that I’m not really happy with.
As you might know, the Window object is the global object in HTML. I’ve tried various ways of making this work with Jurassic:
- Added properties to the global object as you describe elsewhere. While this more or less works, this isn't really a solution for me. To name two reasons: (1) people seem to make assumptions about the (prototype) inheritance tree of Window’s, which is something
- I therefore attempted modifying the constructor to create a new global object. In retrospect, this was a bad idea, since the rest of the initialization code uses Global.
- Eventually I made a small patch that makes it possible to derive from the global object and pass it to Window as reference, e.g. added a protected GlobalObject constructor and
public void SetGlobal(Func<GlobalObject, GlobalObject> fcn)
this.globalObject = fcn(this.globalObject);
This still means I need a helper 'constructor class' that defines part of the prototype chain and an instance class for Window, but does eventually lead to the correct prototype chain.
This basically solves it and gives the correct behavior / prototype chain, but I’d rather prefer a solution that doesn’t involve changing the code of Jurassic... I’ve read up on the other forum posts, but am I correct in the assumption this is currently the
only way to do this?