02.07.2010, в 22:58, Dan Wood написал(а):
> * Create a generic object (to be the global 'window' object) with
> JSObjectMake(ctx, NULL, NULL)
> * Set this object to be the property "window" of the global object with
> JSObjectSetProperty
less.js project page says "will be able to run directly in the browser, as well
as on the server, with node.js". Assuming it's currently capable of the latter,
it sounds like you need to implement whatever node.js requires from its
environment, evaluate node.js, and then evaluate less.js without adding a
window object. Or it could be easier to just run it in a WebView.
When window is not undefined, less.js starts using things that are only
available in browser DOM, such as XMLHttpRequest or
document.getElementsByTagName.
> So I'm kind of stuck. I'm wondering if it's that mysterious wrapping around
> the source code that is confusing me enough to either pass in the wrong
> environment (e.g. a global 'window' object) or extract the results out
> incorrectly.
The reason JavaScript code is often wrapped this way is to avoid defining
functions and variables in global scope.
I'm not sure why exactly you are not getting a "less" property added to your
stub object. It seems that it should be added unless an uncaught exception were
raised (and then you'd get null from JSEvaluateScript, not undefined).
In fact, I cannot replicate your results with jsc command line tool:
$ WebKitBuild/Debug/jsc
> window={}
[object Object]
> load("/Users/ap/Desktop/less-1.0.30.js");
Exception: ReferenceError: Can't find variable: location
- WBR, Alexey Proskuryakov
_______________________________________________
webkit-help mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-help