-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Global scope is always assumed to be "window" #18
Comments
goog.global is the replacement. |
the link seems to be broken. |
I would love to see a java constant added for this name such as |
ModelHelper.createGlobalJavaType always assumes that
window
is the correct name to use:However, this is only correct in a case like DomGlobal, which only makes sense in a normal window context. For classes like Global, this should instead be something like
self
, so that it works both in windows and in workers (as well as other non-browser JS contexts).My proposal would be to change this to invoke
nameAttribute("self")
, since that seems as though it should be valid in window and worker contexts alike (see [1], [2]), but perhaps there is a better, more flexible solution?[1] https://developer.mozilla.org/en-US/docs/Web/API/Window/self
[2] https://developer.mozilla.org/en-US/docs/Web/API/WorkerGlobalScope/self
In the mean time, objects in Global can't be used. Workarounds for others who find this:
Symbol
, make your own jstype to represent it, with a static function instead of a constructor to create itJSON
, make your ownJSONType
with static methods instead of instance methods@JsProperty
-annotated fields.In all of these cases, JsPackage.GLOBAL should be used as the namespace to avoid needing to reference window.
The text was updated successfully, but these errors were encountered: